extensions.c revision af69d88d
17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 37117f1b4Smrg * 4c1f859d4Smrg * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 54a49301eSmrg * Copyright (C) 2009 VMware, Inc. All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 127117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice shall be included 157117f1b4Smrg * in all copies or substantial portions of the Software. 167117f1b4Smrg * 177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 247117f1b4Smrg */ 257117f1b4Smrg 267117f1b4Smrg 273464ebd5Sriastradh/** 283464ebd5Sriastradh * \file 293464ebd5Sriastradh * \brief Extension handling 303464ebd5Sriastradh */ 313464ebd5Sriastradh 323464ebd5Sriastradh 337117f1b4Smrg#include "glheader.h" 347117f1b4Smrg#include "imports.h" 357117f1b4Smrg#include "context.h" 367117f1b4Smrg#include "extensions.h" 37af69d88dSmrg#include "macros.h" 387117f1b4Smrg#include "mtypes.h" 397117f1b4Smrg 40af69d88dSmrgstruct gl_extensions _mesa_extension_override_enables; 41af69d88dSmrgstruct gl_extensions _mesa_extension_override_disables; 42af69d88dSmrgstatic char *extra_extensions = NULL; 43af69d88dSmrgstatic char *cant_disable_extensions = NULL; 44af69d88dSmrg 453464ebd5Sriastradhenum { 463464ebd5Sriastradh DISABLE = 0, 47af69d88dSmrg GLL = 1 << API_OPENGL_COMPAT, /* GL Legacy / Compatibility */ 48af69d88dSmrg GLC = 1 << API_OPENGL_CORE, /* GL Core */ 49af69d88dSmrg GL = (1 << API_OPENGL_COMPAT) | (1 << API_OPENGL_CORE), 503464ebd5Sriastradh ES1 = 1 << API_OPENGLES, 513464ebd5Sriastradh ES2 = 1 << API_OPENGLES2, 52af69d88dSmrg ES3 = 1 << (API_OPENGL_LAST + 1), 533464ebd5Sriastradh}; 547117f1b4Smrg 553464ebd5Sriastradh/** 563464ebd5Sriastradh * \brief An element of the \c extension_table. 573464ebd5Sriastradh */ 583464ebd5Sriastradhstruct extension { 593464ebd5Sriastradh /** Name of extension, such as "GL_ARB_depth_clamp". */ 603464ebd5Sriastradh const char *name; 617117f1b4Smrg 623464ebd5Sriastradh /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ 633464ebd5Sriastradh size_t offset; 647117f1b4Smrg 653464ebd5Sriastradh /** Set of API's in which the extension exists, as a bitset. */ 663464ebd5Sriastradh uint8_t api_set; 673464ebd5Sriastradh 683464ebd5Sriastradh /** Year the extension was proposed or approved. Used to sort the 693464ebd5Sriastradh * extension string chronologically. */ 703464ebd5Sriastradh uint16_t year; 713464ebd5Sriastradh}; 723464ebd5Sriastradh 733464ebd5Sriastradh 743464ebd5Sriastradh/** 753464ebd5Sriastradh * Given a member \c x of struct gl_extensions, return offset of 763464ebd5Sriastradh * \c x in bytes. 773464ebd5Sriastradh */ 783464ebd5Sriastradh#define o(x) offsetof(struct gl_extensions, x) 793464ebd5Sriastradh 803464ebd5Sriastradh 813464ebd5Sriastradh/** 823464ebd5Sriastradh * \brief Table of supported OpenGL extensions for all API's. 837117f1b4Smrg */ 843464ebd5Sriastradhstatic const struct extension extension_table[] = { 853464ebd5Sriastradh /* ARB Extensions */ 863464ebd5Sriastradh { "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL, 2009 }, 87af69d88dSmrg { "GL_ARB_ES3_compatibility", o(ARB_ES3_compatibility), GL, 2012 }, 88af69d88dSmrg { "GL_ARB_arrays_of_arrays", o(ARB_arrays_of_arrays), GL, 2012 }, 89af69d88dSmrg { "GL_ARB_base_instance", o(ARB_base_instance), GL, 2011 }, 903464ebd5Sriastradh { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL, 2009 }, 91af69d88dSmrg { "GL_ARB_buffer_storage", o(ARB_buffer_storage), GL, 2013 }, 92af69d88dSmrg { "GL_ARB_clear_buffer_object", o(dummy_true), GL, 2012 }, 93af69d88dSmrg { "GL_ARB_clear_texture", o(ARB_clear_texture), GL, 2013 }, 943464ebd5Sriastradh { "GL_ARB_color_buffer_float", o(ARB_color_buffer_float), GL, 2004 }, 95af69d88dSmrg { "GL_ARB_compressed_texture_pixel_storage", o(dummy_true), GL, 2011 }, 96af69d88dSmrg { "GL_ARB_compute_shader", o(ARB_compute_shader), GL, 2012 }, 97af69d88dSmrg { "GL_ARB_conditional_render_inverted", o(ARB_conditional_render_inverted), GL, 2014 }, 98af69d88dSmrg { "GL_ARB_copy_buffer", o(dummy_true), GL, 2008 }, 99af69d88dSmrg { "GL_ARB_copy_image", o(ARB_copy_image), GL, 2012 }, 100af69d88dSmrg { "GL_ARB_conservative_depth", o(ARB_conservative_depth), GL, 2011 }, 101af69d88dSmrg { "GL_ARB_debug_output", o(dummy_true), GL, 2009 }, 1023464ebd5Sriastradh { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL, 2008 }, 1033464ebd5Sriastradh { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 }, 104af69d88dSmrg { "GL_ARB_depth_texture", o(ARB_depth_texture), GLL, 2001 }, 105af69d88dSmrg { "GL_ARB_derivative_control", o(ARB_derivative_control), GL, 2014 }, 106af69d88dSmrg { "GL_ARB_draw_buffers", o(dummy_true), GL, 2002 }, 1073464ebd5Sriastradh { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 }, 1083464ebd5Sriastradh { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 }, 109af69d88dSmrg { "GL_ARB_draw_indirect", o(ARB_draw_indirect), GLC, 2010 }, 1103464ebd5Sriastradh { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL, 2008 }, 1113464ebd5Sriastradh { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location), GL, 2009 }, 112af69d88dSmrg { "GL_ARB_explicit_uniform_location", o(ARB_explicit_uniform_location), GL, 2012 }, 1133464ebd5Sriastradh { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL, 2009 }, 114af69d88dSmrg { "GL_ARB_fragment_layer_viewport", o(ARB_fragment_layer_viewport), GLC, 2012 }, 115af69d88dSmrg { "GL_ARB_fragment_program", o(ARB_fragment_program), GLL, 2002 }, 116af69d88dSmrg { "GL_ARB_fragment_program_shadow", o(ARB_fragment_program_shadow), GLL, 2003 }, 1173464ebd5Sriastradh { "GL_ARB_fragment_shader", o(ARB_fragment_shader), GL, 2002 }, 1183464ebd5Sriastradh { "GL_ARB_framebuffer_object", o(ARB_framebuffer_object), GL, 2005 }, 1193464ebd5Sriastradh { "GL_ARB_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL, 1998 }, 120af69d88dSmrg { "GL_ARB_get_program_binary", o(dummy_true), GL, 2010 }, 121af69d88dSmrg { "GL_ARB_gpu_shader5", o(ARB_gpu_shader5), GLC, 2010 }, 122af69d88dSmrg { "GL_ARB_half_float_pixel", o(dummy_true), GL, 2003 }, 1233464ebd5Sriastradh { "GL_ARB_half_float_vertex", o(ARB_half_float_vertex), GL, 2008 }, 1243464ebd5Sriastradh { "GL_ARB_instanced_arrays", o(ARB_instanced_arrays), GL, 2008 }, 125af69d88dSmrg { "GL_ARB_internalformat_query", o(ARB_internalformat_query), GL, 2011 }, 126af69d88dSmrg { "GL_ARB_invalidate_subdata", o(dummy_true), GL, 2012 }, 127af69d88dSmrg { "GL_ARB_map_buffer_alignment", o(dummy_true), GL, 2011 }, 1283464ebd5Sriastradh { "GL_ARB_map_buffer_range", o(ARB_map_buffer_range), GL, 2008 }, 129af69d88dSmrg { "GL_ARB_multi_bind", o(dummy_true), GL, 2013 }, 130af69d88dSmrg { "GL_ARB_multi_draw_indirect", o(ARB_draw_indirect), GLC, 2012 }, 131af69d88dSmrg { "GL_ARB_multisample", o(dummy_true), GLL, 1994 }, 132af69d88dSmrg { "GL_ARB_multitexture", o(dummy_true), GLL, 1998 }, 1333464ebd5Sriastradh { "GL_ARB_occlusion_query2", o(ARB_occlusion_query2), GL, 2003 }, 134af69d88dSmrg { "GL_ARB_occlusion_query", o(ARB_occlusion_query), GLL, 2001 }, 1353464ebd5Sriastradh { "GL_ARB_pixel_buffer_object", o(EXT_pixel_buffer_object), GL, 2004 }, 136af69d88dSmrg { "GL_ARB_point_parameters", o(EXT_point_parameters), GLL, 1997 }, 1373464ebd5Sriastradh { "GL_ARB_point_sprite", o(ARB_point_sprite), GL, 2003 }, 1383464ebd5Sriastradh { "GL_ARB_provoking_vertex", o(EXT_provoking_vertex), GL, 2009 }, 1393464ebd5Sriastradh { "GL_ARB_robustness", o(dummy_true), GL, 2010 }, 140af69d88dSmrg { "GL_ARB_sample_shading", o(ARB_sample_shading), GL, 2009 }, 141af69d88dSmrg { "GL_ARB_sampler_objects", o(dummy_true), GL, 2009 }, 1423464ebd5Sriastradh { "GL_ARB_seamless_cube_map", o(ARB_seamless_cube_map), GL, 2009 }, 143af69d88dSmrg { "GL_ARB_seamless_cubemap_per_texture", o(AMD_seamless_cubemap_per_texture), GL, 2013 }, 144af69d88dSmrg { "GL_ARB_separate_shader_objects", o(dummy_true), GL, 2010 }, 145af69d88dSmrg { "GL_ARB_shader_atomic_counters", o(ARB_shader_atomic_counters), GL, 2011 }, 146af69d88dSmrg { "GL_ARB_shader_bit_encoding", o(ARB_shader_bit_encoding), GL, 2010 }, 147af69d88dSmrg { "GL_ARB_shader_image_load_store", o(ARB_shader_image_load_store), GL, 2011 }, 148af69d88dSmrg { "GL_ARB_shader_objects", o(dummy_true), GL, 2002 }, 1493464ebd5Sriastradh { "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 }, 1503464ebd5Sriastradh { "GL_ARB_shader_texture_lod", o(ARB_shader_texture_lod), GL, 2009 }, 151af69d88dSmrg { "GL_ARB_shading_language_100", o(dummy_true), GLL, 2003 }, 152af69d88dSmrg { "GL_ARB_shading_language_packing", o(ARB_shading_language_packing), GL, 2011 }, 153af69d88dSmrg { "GL_ARB_shading_language_420pack", o(ARB_shading_language_420pack), GL, 2011 }, 154af69d88dSmrg { "GL_ARB_shadow", o(ARB_shadow), GLL, 2001 }, 155af69d88dSmrg { "GL_ARB_stencil_texturing", o(ARB_stencil_texturing), GL, 2012 }, 1563464ebd5Sriastradh { "GL_ARB_sync", o(ARB_sync), GL, 2003 }, 157af69d88dSmrg { "GL_ARB_texture_barrier", o(NV_texture_barrier), GL, 2014 }, 158af69d88dSmrg { "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GLL, 2000 }, 159af69d88dSmrg { "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GLC, 2008 }, 160af69d88dSmrg { "GL_ARB_texture_buffer_object_rgb32", o(ARB_texture_buffer_object_rgb32), GLC, 2009 }, 161af69d88dSmrg { "GL_ARB_texture_buffer_range", o(ARB_texture_buffer_range), GLC, 2012 }, 162af69d88dSmrg { "GL_ARB_texture_compression", o(dummy_true), GLL, 2000 }, 163af69d88dSmrg { "GL_ARB_texture_compression_bptc", o(ARB_texture_compression_bptc), GL, 2010 }, 1643464ebd5Sriastradh { "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL, 2004 }, 165af69d88dSmrg { "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GLL, 1999 }, 166af69d88dSmrg { "GL_ARB_texture_cube_map_array", o(ARB_texture_cube_map_array), GL, 2009 }, 167af69d88dSmrg { "GL_ARB_texture_env_add", o(dummy_true), GLL, 1999 }, 168af69d88dSmrg { "GL_ARB_texture_env_combine", o(ARB_texture_env_combine), GLL, 2001 }, 169af69d88dSmrg { "GL_ARB_texture_env_crossbar", o(ARB_texture_env_crossbar), GLL, 2001 }, 170af69d88dSmrg { "GL_ARB_texture_env_dot3", o(ARB_texture_env_dot3), GLL, 2001 }, 1713464ebd5Sriastradh { "GL_ARB_texture_float", o(ARB_texture_float), GL, 2004 }, 172af69d88dSmrg { "GL_ARB_texture_gather", o(ARB_texture_gather), GL, 2009 }, 173af69d88dSmrg { "GL_ARB_texture_mirrored_repeat", o(dummy_true), GLL, 2001 }, 174af69d88dSmrg { "GL_ARB_texture_mirror_clamp_to_edge", o(ARB_texture_mirror_clamp_to_edge), GL, 2013 }, 1753464ebd5Sriastradh { "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL, 2009 }, 1763464ebd5Sriastradh { "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL, 2003 }, 177af69d88dSmrg { "GL_ARB_texture_query_levels", o(ARB_texture_query_levels), GL, 2012 }, 178af69d88dSmrg { "GL_ARB_texture_query_lod", o(ARB_texture_query_lod), GL, 2009 }, 1793464ebd5Sriastradh { "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL, 2004 }, 1803464ebd5Sriastradh { "GL_ARB_texture_rgb10_a2ui", o(ARB_texture_rgb10_a2ui), GL, 2009 }, 1813464ebd5Sriastradh { "GL_ARB_texture_rg", o(ARB_texture_rg), GL, 2008 }, 182af69d88dSmrg { "GL_ARB_texture_storage", o(dummy_true), GL, 2011 }, 183af69d88dSmrg { "GL_ARB_texture_storage_multisample", o(ARB_texture_multisample), GL, 2012 }, 184af69d88dSmrg { "GL_ARB_texture_view", o(ARB_texture_view), GL, 2012 }, 1853464ebd5Sriastradh { "GL_ARB_texture_swizzle", o(EXT_texture_swizzle), GL, 2008 }, 186af69d88dSmrg { "GL_ARB_timer_query", o(ARB_timer_query), GL, 2010 }, 1873464ebd5Sriastradh { "GL_ARB_transform_feedback2", o(ARB_transform_feedback2), GL, 2010 }, 188af69d88dSmrg { "GL_ARB_transform_feedback3", o(ARB_transform_feedback3), GL, 2010 }, 189af69d88dSmrg { "GL_ARB_transform_feedback_instanced", o(ARB_transform_feedback_instanced), GL, 2011 }, 190af69d88dSmrg { "GL_ARB_transpose_matrix", o(dummy_true), GLL, 1999 }, 191af69d88dSmrg { "GL_ARB_uniform_buffer_object", o(ARB_uniform_buffer_object), GL, 2009 }, 1923464ebd5Sriastradh { "GL_ARB_vertex_array_bgra", o(EXT_vertex_array_bgra), GL, 2008 }, 193af69d88dSmrg { "GL_ARB_vertex_array_object", o(dummy_true), GL, 2006 }, 194af69d88dSmrg { "GL_ARB_vertex_attrib_binding", o(dummy_true), GL, 2012 }, 195af69d88dSmrg { "GL_ARB_vertex_buffer_object", o(dummy_true), GLL, 2003 }, 196af69d88dSmrg { "GL_ARB_vertex_program", o(ARB_vertex_program), GLL, 2002 }, 1973464ebd5Sriastradh { "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL, 2002 }, 198af69d88dSmrg { "GL_ARB_vertex_type_10f_11f_11f_rev", o(ARB_vertex_type_10f_11f_11f_rev), GL, 2013 }, 1993464ebd5Sriastradh { "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL, 2009 }, 200af69d88dSmrg { "GL_ARB_viewport_array", o(ARB_viewport_array), GLC, 2010 }, 201af69d88dSmrg { "GL_ARB_window_pos", o(dummy_true), GLL, 2001 }, 2023464ebd5Sriastradh /* EXT extensions */ 203af69d88dSmrg { "GL_EXT_abgr", o(dummy_true), GL, 1995 }, 204af69d88dSmrg { "GL_EXT_bgra", o(dummy_true), GLL, 1995 }, 205af69d88dSmrg { "GL_EXT_blend_color", o(EXT_blend_color), GLL, 1995 }, 2063464ebd5Sriastradh { "GL_EXT_blend_equation_separate", o(EXT_blend_equation_separate), GL, 2003 }, 207af69d88dSmrg { "GL_EXT_blend_func_separate", o(EXT_blend_func_separate), GLL, 1999 }, 208af69d88dSmrg { "GL_EXT_discard_framebuffer", o(dummy_true), ES1 | ES2, 2009 }, 209af69d88dSmrg { "GL_EXT_blend_minmax", o(EXT_blend_minmax), GLL | ES1 | ES2, 1995 }, 210af69d88dSmrg { "GL_EXT_blend_subtract", o(dummy_true), GLL, 1995 }, 211af69d88dSmrg { "GL_EXT_compiled_vertex_array", o(dummy_true), GLL, 1996 }, 212af69d88dSmrg { "GL_EXT_copy_texture", o(dummy_true), GLL, 1995 }, 2133464ebd5Sriastradh { "GL_EXT_depth_bounds_test", o(EXT_depth_bounds_test), GL, 2002 }, 2143464ebd5Sriastradh { "GL_EXT_draw_buffers2", o(EXT_draw_buffers2), GL, 2006 }, 2153464ebd5Sriastradh { "GL_EXT_draw_instanced", o(ARB_draw_instanced), GL, 2006 }, 216af69d88dSmrg { "GL_EXT_draw_range_elements", o(dummy_true), GLL, 1997 }, 217af69d88dSmrg { "GL_EXT_fog_coord", o(dummy_true), GLL, 1999 }, 218af69d88dSmrg { "GL_EXT_framebuffer_blit", o(dummy_true), GL, 2005 }, 2193464ebd5Sriastradh { "GL_EXT_framebuffer_multisample", o(EXT_framebuffer_multisample), GL, 2005 }, 220af69d88dSmrg { "GL_EXT_framebuffer_multisample_blit_scaled", o(EXT_framebuffer_multisample_blit_scaled), GL, 2011 }, 221af69d88dSmrg { "GL_EXT_framebuffer_object", o(dummy_true), GLL, 2000 }, 2223464ebd5Sriastradh { "GL_EXT_framebuffer_sRGB", o(EXT_framebuffer_sRGB), GL, 1998 }, 223af69d88dSmrg { "GL_EXT_gpu_program_parameters", o(EXT_gpu_program_parameters), GLL, 2006 }, 2243464ebd5Sriastradh { "GL_EXT_gpu_shader4", o(EXT_gpu_shader4), GL, 2006 }, 225af69d88dSmrg { "GL_EXT_map_buffer_range", o(ARB_map_buffer_range), ES1 | ES2, 2012 }, 226af69d88dSmrg { "GL_EXT_multi_draw_arrays", o(dummy_true), GLL | ES1 | ES2, 1999 }, 227af69d88dSmrg { "GL_EXT_packed_depth_stencil", o(dummy_true), GL, 2005 }, 2283464ebd5Sriastradh { "GL_EXT_packed_float", o(EXT_packed_float), GL, 2004 }, 229af69d88dSmrg { "GL_EXT_packed_pixels", o(dummy_true), GLL, 1997 }, 2303464ebd5Sriastradh { "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), GL, 2004 }, 231af69d88dSmrg { "GL_EXT_point_parameters", o(EXT_point_parameters), GLL, 1997 }, 232af69d88dSmrg { "GL_EXT_polygon_offset", o(dummy_true), GLL, 1995 }, 2333464ebd5Sriastradh { "GL_EXT_provoking_vertex", o(EXT_provoking_vertex), GL, 2009 }, 234af69d88dSmrg { "GL_EXT_rescale_normal", o(dummy_true), GLL, 1997 }, 235af69d88dSmrg { "GL_EXT_secondary_color", o(dummy_true), GLL, 1999 }, 236af69d88dSmrg { "GL_EXT_separate_shader_objects", o(dummy_true), ES2, 2013 }, 237af69d88dSmrg { "GL_EXT_separate_specular_color", o(dummy_true), GLL, 1997 }, 238af69d88dSmrg { "GL_EXT_shader_integer_mix", o(EXT_shader_integer_mix), GL | ES3, 2013 }, 239af69d88dSmrg { "GL_EXT_shadow_funcs", o(ARB_shadow), GLL, 2002 }, 240af69d88dSmrg { "GL_EXT_stencil_two_side", o(EXT_stencil_two_side), GLL, 2001 }, 241af69d88dSmrg { "GL_EXT_stencil_wrap", o(dummy_true), GLL, 2002 }, 242af69d88dSmrg { "GL_EXT_subtexture", o(dummy_true), GLL, 1995 }, 243af69d88dSmrg { "GL_EXT_texture3D", o(EXT_texture3D), GLL, 1996 }, 2443464ebd5Sriastradh { "GL_EXT_texture_array", o(EXT_texture_array), GL, 2006 }, 245af69d88dSmrg { "GL_EXT_texture_compression_dxt1", o(ANGLE_texture_compression_dxt), GL | ES1 | ES2, 2004 }, 246af69d88dSmrg { "GL_ANGLE_texture_compression_dxt3", o(ANGLE_texture_compression_dxt), GL | ES1 | ES2, 2011 }, 247af69d88dSmrg { "GL_ANGLE_texture_compression_dxt5", o(ANGLE_texture_compression_dxt), GL | ES1 | ES2, 2011 }, 2483464ebd5Sriastradh { "GL_EXT_texture_compression_latc", o(EXT_texture_compression_latc), GL, 2006 }, 2493464ebd5Sriastradh { "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL, 2004 }, 2503464ebd5Sriastradh { "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL, 2000 }, 251af69d88dSmrg { "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GLL, 2001 }, 252af69d88dSmrg { "GL_EXT_texture_edge_clamp", o(dummy_true), GLL, 1997 }, 253af69d88dSmrg { "GL_EXT_texture_env_add", o(dummy_true), GLL, 1999 }, 254af69d88dSmrg { "GL_EXT_texture_env_combine", o(dummy_true), GLL, 2000 }, 255af69d88dSmrg { "GL_EXT_texture_env_dot3", o(EXT_texture_env_dot3), GLL, 2000 }, 2563464ebd5Sriastradh { "GL_EXT_texture_filter_anisotropic", o(EXT_texture_filter_anisotropic), GL | ES1 | ES2, 1999 }, 257af69d88dSmrg { "GL_EXT_texture_format_BGRA8888", o(dummy_true), ES1 | ES2, 2005 }, 258af69d88dSmrg { "GL_EXT_texture_rg", o(ARB_texture_rg), ES2, 2011 }, 259af69d88dSmrg { "GL_EXT_read_format_bgra", o(dummy_true), ES1 | ES2, 2009 }, 2603464ebd5Sriastradh { "GL_EXT_texture_integer", o(EXT_texture_integer), GL, 2006 }, 261af69d88dSmrg { "GL_EXT_texture_lod_bias", o(dummy_true), GLL | ES1, 1999 }, 2623464ebd5Sriastradh { "GL_EXT_texture_mirror_clamp", o(EXT_texture_mirror_clamp), GL, 2004 }, 263af69d88dSmrg { "GL_EXT_texture_object", o(dummy_true), GLL, 1995 }, 264af69d88dSmrg { "GL_EXT_texture", o(dummy_true), GLL, 1996 }, 265af69d88dSmrg { "GL_EXT_texture_rectangle", o(NV_texture_rectangle), GLL, 2004 }, 2663464ebd5Sriastradh { "GL_EXT_texture_shared_exponent", o(EXT_texture_shared_exponent), GL, 2004 }, 2673464ebd5Sriastradh { "GL_EXT_texture_snorm", o(EXT_texture_snorm), GL, 2009 }, 2683464ebd5Sriastradh { "GL_EXT_texture_sRGB", o(EXT_texture_sRGB), GL, 2004 }, 2693464ebd5Sriastradh { "GL_EXT_texture_sRGB_decode", o(EXT_texture_sRGB_decode), GL, 2006 }, 2703464ebd5Sriastradh { "GL_EXT_texture_swizzle", o(EXT_texture_swizzle), GL, 2008 }, 2713464ebd5Sriastradh { "GL_EXT_texture_type_2_10_10_10_REV", o(dummy_true), ES2, 2008 }, 2723464ebd5Sriastradh { "GL_EXT_timer_query", o(EXT_timer_query), GL, 2006 }, 2733464ebd5Sriastradh { "GL_EXT_transform_feedback", o(EXT_transform_feedback), GL, 2011 }, 274af69d88dSmrg { "GL_EXT_unpack_subimage", o(dummy_true), ES2, 2011 }, 2753464ebd5Sriastradh { "GL_EXT_vertex_array_bgra", o(EXT_vertex_array_bgra), GL, 2008 }, 276af69d88dSmrg { "GL_EXT_vertex_array", o(dummy_true), GLL, 1995 }, 277af69d88dSmrg { "GL_EXT_color_buffer_float", o(dummy_true), ES3, 2013 }, 2783464ebd5Sriastradh 2793464ebd5Sriastradh /* OES extensions */ 2803464ebd5Sriastradh { "GL_OES_blend_equation_separate", o(EXT_blend_equation_separate), ES1, 2009 }, 2813464ebd5Sriastradh { "GL_OES_blend_func_separate", o(EXT_blend_func_separate), ES1, 2009 }, 282af69d88dSmrg { "GL_OES_blend_subtract", o(dummy_true), ES1, 2009 }, 2833464ebd5Sriastradh { "GL_OES_byte_coordinates", o(dummy_true), ES1, 2002 }, 284af69d88dSmrg { "GL_OES_compressed_ETC1_RGB8_texture", o(OES_compressed_ETC1_RGB8_texture), ES1 | ES2, 2005 }, 2853464ebd5Sriastradh { "GL_OES_compressed_paletted_texture", o(dummy_true), ES1, 2003 }, 286af69d88dSmrg { "GL_OES_depth24", o(dummy_true), ES1 | ES2, 2005 }, 2873464ebd5Sriastradh { "GL_OES_depth32", o(dummy_false), DISABLE, 2005 }, 2883464ebd5Sriastradh { "GL_OES_depth_texture", o(ARB_depth_texture), ES2, 2006 }, 289af69d88dSmrg { "GL_OES_depth_texture_cube_map", o(OES_depth_texture_cube_map), ES2, 2012 }, 290af69d88dSmrg { "GL_OES_draw_texture", o(OES_draw_texture), ES1, 2004 }, 2913464ebd5Sriastradh /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */ 2923464ebd5Sriastradh { "GL_OES_EGL_image", o(OES_EGL_image), GL | ES1 | ES2, 2006 }, 293af69d88dSmrg { "GL_OES_EGL_image_external", o(OES_EGL_image_external), ES1 | ES2, 2010 }, 294af69d88dSmrg { "GL_OES_element_index_uint", o(dummy_true), ES1 | ES2, 2005 }, 295af69d88dSmrg { "GL_OES_fbo_render_mipmap", o(dummy_true), ES1 | ES2, 2005 }, 2963464ebd5Sriastradh { "GL_OES_fixed_point", o(dummy_true), ES1, 2002 }, 297af69d88dSmrg { "GL_OES_framebuffer_object", o(dummy_true), ES1, 2005 }, 298af69d88dSmrg { "GL_OES_get_program_binary", o(dummy_true), ES2, 2008 }, 299af69d88dSmrg { "GL_OES_mapbuffer", o(dummy_true), ES1 | ES2, 2005 }, 300af69d88dSmrg { "GL_OES_packed_depth_stencil", o(dummy_true), ES1 | ES2, 2007 }, 3013464ebd5Sriastradh { "GL_OES_point_size_array", o(dummy_true), ES1, 2004 }, 3023464ebd5Sriastradh { "GL_OES_point_sprite", o(ARB_point_sprite), ES1, 2004 }, 3033464ebd5Sriastradh { "GL_OES_query_matrix", o(dummy_true), ES1, 2003 }, 304af69d88dSmrg { "GL_OES_read_format", o(dummy_true), GL | ES1, 2003 }, 305af69d88dSmrg { "GL_OES_rgb8_rgba8", o(dummy_true), ES1 | ES2, 2005 }, 3063464ebd5Sriastradh { "GL_OES_single_precision", o(dummy_true), ES1, 2003 }, 3073464ebd5Sriastradh { "GL_OES_standard_derivatives", o(OES_standard_derivatives), ES2, 2005 }, 3083464ebd5Sriastradh { "GL_OES_stencil1", o(dummy_false), DISABLE, 2005 }, 3093464ebd5Sriastradh { "GL_OES_stencil4", o(dummy_false), DISABLE, 2005 }, 310af69d88dSmrg { "GL_OES_stencil8", o(dummy_true), ES1 | ES2, 2005 }, 311af69d88dSmrg { "GL_OES_stencil_wrap", o(dummy_true), ES1, 2002 }, 312af69d88dSmrg { "GL_OES_surfaceless_context", o(dummy_true), ES1 | ES2, 2012 }, 3133464ebd5Sriastradh { "GL_OES_texture_3D", o(EXT_texture3D), ES2, 2005 }, 3143464ebd5Sriastradh { "GL_OES_texture_cube_map", o(ARB_texture_cube_map), ES1, 2007 }, 3153464ebd5Sriastradh { "GL_OES_texture_env_crossbar", o(ARB_texture_env_crossbar), ES1, 2005 }, 316af69d88dSmrg { "GL_OES_texture_mirrored_repeat", o(dummy_true), ES1, 2005 }, 317af69d88dSmrg { "GL_OES_texture_npot", o(ARB_texture_non_power_of_two), ES1 | ES2, 2005 }, 318af69d88dSmrg { "GL_OES_vertex_array_object", o(dummy_true), ES1 | ES2, 2010 }, 319af69d88dSmrg 320af69d88dSmrg /* KHR extensions */ 321af69d88dSmrg { "GL_KHR_debug", o(dummy_true), GL, 2012 }, 3223464ebd5Sriastradh 3233464ebd5Sriastradh /* Vendor extensions */ 3243464ebd5Sriastradh { "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL, 1999 }, 325af69d88dSmrg { "GL_AMD_conservative_depth", o(ARB_conservative_depth), GL, 2009 }, 3263464ebd5Sriastradh { "GL_AMD_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 }, 327af69d88dSmrg { "GL_AMD_performance_monitor", o(AMD_performance_monitor), GL, 2007 }, 3283464ebd5Sriastradh { "GL_AMD_seamless_cubemap_per_texture", o(AMD_seamless_cubemap_per_texture), GL, 2009 }, 3293464ebd5Sriastradh { "GL_AMD_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 }, 330af69d88dSmrg { "GL_AMD_shader_trinary_minmax", o(dummy_true), GL, 2012 }, 331af69d88dSmrg { "GL_AMD_vertex_shader_layer", o(AMD_vertex_shader_layer), GLC, 2012 }, 332af69d88dSmrg { "GL_AMD_vertex_shader_viewport_index", o(AMD_vertex_shader_viewport_index), GLC, 2012 }, 3333464ebd5Sriastradh { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL, 2006 }, 334af69d88dSmrg { "GL_APPLE_packed_pixels", o(dummy_true), GLL, 2002 }, 335af69d88dSmrg { "GL_APPLE_texture_max_level", o(dummy_true), ES1 | ES2, 2009 }, 336af69d88dSmrg { "GL_APPLE_vertex_array_object", o(dummy_true), GLL, 2002 }, 3373464ebd5Sriastradh { "GL_ATI_blend_equation_separate", o(EXT_blend_equation_separate), GL, 2003 }, 338af69d88dSmrg { "GL_ATI_draw_buffers", o(dummy_true), GLL, 2002 }, 339af69d88dSmrg { "GL_ATI_fragment_shader", o(ATI_fragment_shader), GLL, 2001 }, 340af69d88dSmrg { "GL_ATI_separate_stencil", o(ATI_separate_stencil), GLL, 2006 }, 3413464ebd5Sriastradh { "GL_ATI_texture_compression_3dc", o(ATI_texture_compression_3dc), GL, 2004 }, 342af69d88dSmrg { "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GLL, 2002 }, 3433464ebd5Sriastradh { "GL_ATI_texture_float", o(ARB_texture_float), GL, 2002 }, 3443464ebd5Sriastradh { "GL_ATI_texture_mirror_once", o(ATI_texture_mirror_once), GL, 2006 }, 345af69d88dSmrg { "GL_IBM_multimode_draw_arrays", o(dummy_true), GL, 1998 }, 346af69d88dSmrg { "GL_IBM_rasterpos_clip", o(dummy_true), GLL, 1996 }, 347af69d88dSmrg { "GL_IBM_texture_mirrored_repeat", o(dummy_true), GLL, 1998 }, 348af69d88dSmrg { "GL_INGR_blend_func_separate", o(EXT_blend_func_separate), GLL, 1999 }, 349af69d88dSmrg { "GL_INTEL_performance_query", o(INTEL_performance_query), GL | ES2, 2013 }, 3503464ebd5Sriastradh { "GL_MESA_pack_invert", o(MESA_pack_invert), GL, 2002 }, 3513464ebd5Sriastradh { "GL_MESA_texture_signed_rgba", o(EXT_texture_snorm), GL, 2009 }, 352af69d88dSmrg { "GL_MESA_window_pos", o(dummy_true), GLL, 2000 }, 3533464ebd5Sriastradh { "GL_MESA_ycbcr_texture", o(MESA_ycbcr_texture), GL, 2002 }, 354af69d88dSmrg { "GL_NV_blend_square", o(dummy_true), GLL, 1999 }, 3553464ebd5Sriastradh { "GL_NV_conditional_render", o(NV_conditional_render), GL, 2008 }, 3563464ebd5Sriastradh { "GL_NV_depth_clamp", o(ARB_depth_clamp), GL, 2001 }, 357af69d88dSmrg { "GL_NV_draw_buffers", o(dummy_true), ES2, 2011 }, 358af69d88dSmrg { "GL_NV_fbo_color_attachments", o(dummy_true), ES2, 2010 }, 359af69d88dSmrg { "GL_NV_fog_distance", o(NV_fog_distance), GLL, 2001 }, 360af69d88dSmrg { "GL_NV_fragment_program_option", o(NV_fragment_program_option), GLL, 2005 }, 361af69d88dSmrg { "GL_NV_light_max_exponent", o(dummy_true), GLL, 1999 }, 362af69d88dSmrg { "GL_NV_packed_depth_stencil", o(dummy_true), GL, 2000 }, 3633464ebd5Sriastradh { "GL_NV_point_sprite", o(NV_point_sprite), GL, 2001 }, 364af69d88dSmrg { "GL_NV_primitive_restart", o(NV_primitive_restart), GLL, 2002 }, 365af69d88dSmrg { "GL_NV_read_buffer", o(dummy_true), ES2, 2011 }, 366af69d88dSmrg { "GL_NV_texgen_reflection", o(dummy_true), GLL, 1999 }, 3673464ebd5Sriastradh { "GL_NV_texture_barrier", o(NV_texture_barrier), GL, 2009 }, 368af69d88dSmrg { "GL_NV_texture_env_combine4", o(NV_texture_env_combine4), GLL, 1999 }, 369af69d88dSmrg { "GL_NV_texture_rectangle", o(NV_texture_rectangle), GLL, 2000 }, 370af69d88dSmrg { "GL_NV_vdpau_interop", o(NV_vdpau_interop), GL, 2010 }, 371af69d88dSmrg { "GL_S3_s3tc", o(ANGLE_texture_compression_dxt), GL, 1999 }, 372af69d88dSmrg { "GL_SGIS_generate_mipmap", o(dummy_true), GLL, 1997 }, 373af69d88dSmrg { "GL_SGIS_texture_border_clamp", o(ARB_texture_border_clamp), GLL, 1997 }, 374af69d88dSmrg { "GL_SGIS_texture_edge_clamp", o(dummy_true), GLL, 1997 }, 375af69d88dSmrg { "GL_SGIS_texture_lod", o(dummy_true), GLL, 1997 }, 376af69d88dSmrg { "GL_SUN_multi_draw_arrays", o(dummy_true), GLL, 1999 }, 3773464ebd5Sriastradh 3783464ebd5Sriastradh { 0, 0, 0, 0 }, 3797117f1b4Smrg}; 3807117f1b4Smrg 3817117f1b4Smrg 3823464ebd5Sriastradh/** 3833464ebd5Sriastradh * Given an extension name, lookup up the corresponding member of struct 3843464ebd5Sriastradh * gl_extensions and return that member's offset (in bytes). If the name is 3853464ebd5Sriastradh * not found in the \c extension_table, return 0. 3863464ebd5Sriastradh * 3873464ebd5Sriastradh * \param name Name of extension. 3883464ebd5Sriastradh * \return Offset of member in struct gl_extensions. 3893464ebd5Sriastradh */ 3903464ebd5Sriastradhstatic size_t 3913464ebd5Sriastradhname_to_offset(const char* name) 3923464ebd5Sriastradh{ 3933464ebd5Sriastradh const struct extension *i; 3943464ebd5Sriastradh 3953464ebd5Sriastradh if (name == 0) 3963464ebd5Sriastradh return 0; 3973464ebd5Sriastradh 3983464ebd5Sriastradh for (i = extension_table; i->name != 0; ++i) { 3993464ebd5Sriastradh if (strcmp(name, i->name) == 0) 4003464ebd5Sriastradh return i->offset; 4013464ebd5Sriastradh } 4023464ebd5Sriastradh 4033464ebd5Sriastradh return 0; 4043464ebd5Sriastradh} 4053464ebd5Sriastradh 4063464ebd5Sriastradh/** 407af69d88dSmrg * Overrides extensions in \c ctx based on the values in 408af69d88dSmrg * _mesa_extension_override_enables and _mesa_extension_override_disables. 4093464ebd5Sriastradh */ 410af69d88dSmrgstatic void 411af69d88dSmrgoverride_extensions_in_context(struct gl_context *ctx) 412af69d88dSmrg{ 413af69d88dSmrg const struct extension *i; 414af69d88dSmrg const GLboolean *enables = 415af69d88dSmrg (GLboolean*) &_mesa_extension_override_enables; 416af69d88dSmrg const GLboolean *disables = 417af69d88dSmrg (GLboolean*) &_mesa_extension_override_disables; 418af69d88dSmrg GLboolean *ctx_ext = (GLboolean*)&ctx->Extensions; 419af69d88dSmrg 420af69d88dSmrg for (i = extension_table; i->name != 0; ++i) { 421af69d88dSmrg size_t offset = i->offset; 422af69d88dSmrg assert(!enables[offset] || !disables[offset]); 423af69d88dSmrg if (enables[offset]) { 424af69d88dSmrg ctx_ext[offset] = 1; 425af69d88dSmrg } else if (disables[offset]) { 426af69d88dSmrg ctx_ext[offset] = 0; 427af69d88dSmrg } 428af69d88dSmrg } 429af69d88dSmrg} 4303464ebd5Sriastradh 4317117f1b4Smrg 4327117f1b4Smrg/** 4337117f1b4Smrg * Enable all extensions suitable for a software-only renderer. 4347117f1b4Smrg * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc. 4357117f1b4Smrg */ 4367117f1b4Smrgvoid 4373464ebd5Sriastradh_mesa_enable_sw_extensions(struct gl_context *ctx) 4387117f1b4Smrg{ 4394a49301eSmrg ctx->Extensions.ARB_depth_clamp = GL_TRUE; 4407117f1b4Smrg ctx->Extensions.ARB_depth_texture = GL_TRUE; 4414a49301eSmrg ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE; 4423464ebd5Sriastradh ctx->Extensions.ARB_draw_instanced = GL_TRUE; 4433464ebd5Sriastradh ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE; 444cdc920a0Smrg ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; 4457117f1b4Smrg ctx->Extensions.ARB_fragment_program = GL_TRUE; 446c1f859d4Smrg ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE; 4477117f1b4Smrg ctx->Extensions.ARB_fragment_shader = GL_TRUE; 4484a49301eSmrg ctx->Extensions.ARB_framebuffer_object = GL_TRUE; 449cdc920a0Smrg ctx->Extensions.ARB_half_float_vertex = GL_TRUE; 4504a49301eSmrg ctx->Extensions.ARB_map_buffer_range = GL_TRUE; 4517117f1b4Smrg ctx->Extensions.ARB_occlusion_query = GL_TRUE; 4523464ebd5Sriastradh ctx->Extensions.ARB_occlusion_query2 = GL_TRUE; 4537117f1b4Smrg ctx->Extensions.ARB_point_sprite = GL_TRUE; 4547117f1b4Smrg ctx->Extensions.ARB_shadow = GL_TRUE; 4557117f1b4Smrg ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; 456af69d88dSmrg ctx->Extensions.ARB_texture_compression_bptc = GL_TRUE; 4577117f1b4Smrg ctx->Extensions.ARB_texture_cube_map = GL_TRUE; 4587117f1b4Smrg ctx->Extensions.ARB_texture_env_combine = GL_TRUE; 4597117f1b4Smrg ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE; 4607117f1b4Smrg ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE; 461af69d88dSmrg#ifdef TEXTURE_FLOAT_ENABLED 462af69d88dSmrg ctx->Extensions.ARB_texture_float = GL_TRUE; 463af69d88dSmrg#endif 464af69d88dSmrg ctx->Extensions.ARB_texture_mirror_clamp_to_edge = GL_TRUE; 4657117f1b4Smrg ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; 4663464ebd5Sriastradh ctx->Extensions.ARB_texture_rg = GL_TRUE; 4673464ebd5Sriastradh ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE; 4687117f1b4Smrg ctx->Extensions.ARB_vertex_program = GL_TRUE; 4697117f1b4Smrg ctx->Extensions.ARB_vertex_shader = GL_TRUE; 4704a49301eSmrg ctx->Extensions.ARB_sync = GL_TRUE; 471cdc920a0Smrg ctx->Extensions.APPLE_object_purgeable = GL_TRUE; 4727117f1b4Smrg ctx->Extensions.ATI_fragment_shader = GL_TRUE; 4733464ebd5Sriastradh ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE; 4747117f1b4Smrg ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE; 4757117f1b4Smrg ctx->Extensions.ATI_texture_mirror_once = GL_TRUE; 4767117f1b4Smrg ctx->Extensions.ATI_separate_stencil = GL_TRUE; 4777117f1b4Smrg ctx->Extensions.EXT_blend_color = GL_TRUE; 4787117f1b4Smrg ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; 4797117f1b4Smrg ctx->Extensions.EXT_blend_func_separate = GL_TRUE; 4807117f1b4Smrg ctx->Extensions.EXT_blend_minmax = GL_TRUE; 4817117f1b4Smrg ctx->Extensions.EXT_depth_bounds_test = GL_TRUE; 482cdc920a0Smrg ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; 4837117f1b4Smrg ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; 4847117f1b4Smrg ctx->Extensions.EXT_point_parameters = GL_TRUE; 4854a49301eSmrg ctx->Extensions.EXT_provoking_vertex = GL_TRUE; 486c1f859d4Smrg ctx->Extensions.EXT_stencil_two_side = GL_TRUE; 487cdc920a0Smrg ctx->Extensions.EXT_texture_array = GL_TRUE; 4883464ebd5Sriastradh ctx->Extensions.EXT_texture_compression_latc = GL_TRUE; 4897117f1b4Smrg ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE; 4903464ebd5Sriastradh ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE; 4917117f1b4Smrg ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE; 4923464ebd5Sriastradh ctx->Extensions.EXT_texture_shared_exponent = GL_TRUE; 4937117f1b4Smrg ctx->Extensions.EXT_texture_sRGB = GL_TRUE; 4943464ebd5Sriastradh ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE; 4954a49301eSmrg ctx->Extensions.EXT_texture_swizzle = GL_TRUE; 4963464ebd5Sriastradh /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/ 4974a49301eSmrg ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; 4987117f1b4Smrg ctx->Extensions.MESA_pack_invert = GL_TRUE; 4997117f1b4Smrg ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; 500cdc920a0Smrg ctx->Extensions.NV_conditional_render = GL_TRUE; 5017117f1b4Smrg ctx->Extensions.NV_point_sprite = GL_TRUE; 5024a49301eSmrg ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; 5037117f1b4Smrg ctx->Extensions.NV_texture_rectangle = GL_TRUE; 5044a49301eSmrg ctx->Extensions.NV_fragment_program_option = GL_TRUE; 5057117f1b4Smrg ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; 506af69d88dSmrg ctx->Extensions.OES_standard_derivatives = GL_TRUE; 507af69d88dSmrg ctx->Extensions.TDFX_texture_compression_FXT1 = GL_TRUE; 508c1f859d4Smrg if (ctx->Mesa_DXTn) { 509af69d88dSmrg ctx->Extensions.ANGLE_texture_compression_dxt = GL_TRUE; 510af69d88dSmrg ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; 511c1f859d4Smrg } 5127117f1b4Smrg} 5137117f1b4Smrg 5147117f1b4Smrg/** 5157117f1b4Smrg * Either enable or disable the named extension. 516af69d88dSmrg * \return offset of extensions withint `ext' or 0 if extension is not known 5177117f1b4Smrg */ 518af69d88dSmrgstatic size_t 519af69d88dSmrgset_extension(struct gl_extensions *ext, const char *name, GLboolean state) 5207117f1b4Smrg{ 5213464ebd5Sriastradh size_t offset; 5227117f1b4Smrg 5233464ebd5Sriastradh offset = name_to_offset(name); 524af69d88dSmrg if (offset != 0 && (offset != o(dummy_true) || state != GL_FALSE)) { 525af69d88dSmrg ((GLboolean *) ext)[offset] = state; 5267117f1b4Smrg } 5277117f1b4Smrg 528af69d88dSmrg return offset; 529af69d88dSmrg} 5307117f1b4Smrg 5317117f1b4Smrg/** 532af69d88dSmrg * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable. 533af69d88dSmrg * 534af69d88dSmrg * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to 535af69d88dSmrg * enable or disable. The list is processed thus: 536af69d88dSmrg * - Enable recognized extension names that are prefixed with '+'. 537af69d88dSmrg * - Disable recognized extension names that are prefixed with '-'. 538af69d88dSmrg * - Enable recognized extension names that are not prefixed. 539af69d88dSmrg * - Collect unrecognized extension names in a new string. 540af69d88dSmrg * 541af69d88dSmrg * \c MESA_EXTENSION_OVERRIDE was previously parsed during 542af69d88dSmrg * _mesa_one_time_init_extension_overrides. We just use the results of that 543af69d88dSmrg * parsing in this function. 544af69d88dSmrg * 545af69d88dSmrg * \return Space-separated list of unrecognized extension names (which must 546af69d88dSmrg * be freed). Does not return \c NULL. 5477117f1b4Smrg */ 548af69d88dSmrgstatic char * 549af69d88dSmrgget_extension_override( struct gl_context *ctx ) 5507117f1b4Smrg{ 551af69d88dSmrg override_extensions_in_context(ctx); 5527117f1b4Smrg 553af69d88dSmrg if (cant_disable_extensions != NULL) { 554af69d88dSmrg _mesa_problem(ctx, 555af69d88dSmrg "Trying to disable permanently enabled extensions: %s", 556af69d88dSmrg cant_disable_extensions); 557af69d88dSmrg } 5587117f1b4Smrg 559af69d88dSmrg if (extra_extensions == NULL) { 560af69d88dSmrg return calloc(1, sizeof(char)); 561af69d88dSmrg } else { 562af69d88dSmrg _mesa_problem(ctx, "Trying to enable unknown extensions: %s", 563af69d88dSmrg extra_extensions); 564af69d88dSmrg return strdup(extra_extensions); 565af69d88dSmrg } 5667117f1b4Smrg} 5677117f1b4Smrg 5687117f1b4Smrg 569cdc920a0Smrg/** 570af69d88dSmrg * \brief Free extra_extensions and cant_disable_extensions strings 571af69d88dSmrg * 572af69d88dSmrg * These strings are allocated early during the first context creation by 573af69d88dSmrg * _mesa_one_time_init_extension_overrides. 574cdc920a0Smrg */ 575af69d88dSmrgstatic void 576af69d88dSmrgfree_unknown_extensions_strings(void) 577cdc920a0Smrg{ 578af69d88dSmrg free(extra_extensions); 579af69d88dSmrg free(cant_disable_extensions); 580cdc920a0Smrg} 581cdc920a0Smrg 582cdc920a0Smrg 5837117f1b4Smrg/** 584af69d88dSmrg * \brief Initialize extension override tables. 5853464ebd5Sriastradh * 586af69d88dSmrg * This should be called one time early during first context initialization. 5877117f1b4Smrg */ 588af69d88dSmrgvoid 589af69d88dSmrg_mesa_one_time_init_extension_overrides(void) 5907117f1b4Smrg{ 5913464ebd5Sriastradh const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); 5923464ebd5Sriastradh char *env; 5933464ebd5Sriastradh char *ext; 5943464ebd5Sriastradh int len; 595af69d88dSmrg size_t offset; 596af69d88dSmrg 597af69d88dSmrg atexit(free_unknown_extensions_strings); 598af69d88dSmrg 599af69d88dSmrg memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions)); 600af69d88dSmrg memset(&_mesa_extension_override_disables, 0, sizeof(struct gl_extensions)); 6013464ebd5Sriastradh 6023464ebd5Sriastradh if (env_const == NULL) { 603af69d88dSmrg return; 6043464ebd5Sriastradh } 6057117f1b4Smrg 6063464ebd5Sriastradh /* extra_exts: List of unrecognized extensions. */ 607af69d88dSmrg extra_extensions = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char)); 608af69d88dSmrg cant_disable_extensions = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char)); 6093464ebd5Sriastradh 6103464ebd5Sriastradh /* Copy env_const because strtok() is destructive. */ 6113464ebd5Sriastradh env = strdup(env_const); 6123464ebd5Sriastradh for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) { 6133464ebd5Sriastradh int enable; 614af69d88dSmrg bool recognized; 6153464ebd5Sriastradh switch (ext[0]) { 6163464ebd5Sriastradh case '+': 6173464ebd5Sriastradh enable = 1; 6183464ebd5Sriastradh ++ext; 6193464ebd5Sriastradh break; 6203464ebd5Sriastradh case '-': 6213464ebd5Sriastradh enable = 0; 6223464ebd5Sriastradh ++ext; 6233464ebd5Sriastradh break; 6243464ebd5Sriastradh default: 6253464ebd5Sriastradh enable = 1; 6263464ebd5Sriastradh break; 6273464ebd5Sriastradh } 628af69d88dSmrg 629af69d88dSmrg offset = set_extension(&_mesa_extension_override_enables, ext, enable); 630af69d88dSmrg if (offset != 0 && (offset != o(dummy_true) || enable != GL_FALSE)) { 631af69d88dSmrg ((GLboolean *) &_mesa_extension_override_disables)[offset] = !enable; 632af69d88dSmrg recognized = true; 633af69d88dSmrg } else { 634af69d88dSmrg recognized = false; 635af69d88dSmrg } 636af69d88dSmrg 6373464ebd5Sriastradh if (!recognized) { 638af69d88dSmrg if (enable) { 639af69d88dSmrg strcat(extra_extensions, ext); 640af69d88dSmrg strcat(extra_extensions, " "); 641af69d88dSmrg } else if (offset == o(dummy_true)) { 642af69d88dSmrg strcat(cant_disable_extensions, ext); 643af69d88dSmrg strcat(cant_disable_extensions, " "); 644af69d88dSmrg } 6457117f1b4Smrg } 6467117f1b4Smrg } 6477117f1b4Smrg 648af69d88dSmrg free(env); 6497117f1b4Smrg 650af69d88dSmrg /* Remove trailing space, and free if unused. */ 651af69d88dSmrg len = strlen(extra_extensions); 652af69d88dSmrg if (len == 0) { 653af69d88dSmrg free(extra_extensions); 654af69d88dSmrg extra_extensions = NULL; 655af69d88dSmrg } else if (extra_extensions[len - 1] == ' ') { 656af69d88dSmrg extra_extensions[len - 1] = '\0'; 657af69d88dSmrg } 658af69d88dSmrg len = strlen(cant_disable_extensions); 659af69d88dSmrg if (len == 0) { 660af69d88dSmrg free(cant_disable_extensions); 661af69d88dSmrg cant_disable_extensions = NULL; 662af69d88dSmrg } else if (cant_disable_extensions[len - 1] == ' ') { 663af69d88dSmrg cant_disable_extensions[len - 1] = '\0'; 664af69d88dSmrg } 6654a49301eSmrg} 6664a49301eSmrg 6674a49301eSmrg 6684a49301eSmrg/** 6693464ebd5Sriastradh * \brief Initialize extension tables and enable default extensions. 6703464ebd5Sriastradh * 6713464ebd5Sriastradh * This should be called during context initialization. 6723464ebd5Sriastradh * Note: Sets gl_extensions.dummy_true to true. 6734a49301eSmrg */ 6743464ebd5Sriastradhvoid 675af69d88dSmrg_mesa_init_extensions(struct gl_extensions *extensions) 6764a49301eSmrg{ 677af69d88dSmrg GLboolean *base = (GLboolean *) extensions; 6783464ebd5Sriastradh GLboolean *sentinel = base + o(extension_sentinel); 6793464ebd5Sriastradh GLboolean *i; 6803464ebd5Sriastradh 6813464ebd5Sriastradh /* First, turn all extensions off. */ 6823464ebd5Sriastradh for (i = base; i != sentinel; ++i) 6833464ebd5Sriastradh *i = GL_FALSE; 6843464ebd5Sriastradh 6853464ebd5Sriastradh /* Then, selectively turn default extensions on. */ 686af69d88dSmrg extensions->dummy_true = GL_TRUE; 687af69d88dSmrg extensions->EXT_texture3D = GL_TRUE; 6883464ebd5Sriastradh} 6894a49301eSmrg 6904a49301eSmrg 6913464ebd5Sriastradhtypedef unsigned short extension_index; 6924a49301eSmrg 6934a49301eSmrg 6947117f1b4Smrg/** 6953464ebd5Sriastradh * Compare two entries of the extensions table. Sorts first by year, 6963464ebd5Sriastradh * then by name. 6973464ebd5Sriastradh * 6983464ebd5Sriastradh * Arguments are indices into extension_table. 6997117f1b4Smrg */ 7003464ebd5Sriastradhstatic int 7013464ebd5Sriastradhextension_compare(const void *p1, const void *p2) 7027117f1b4Smrg{ 7033464ebd5Sriastradh extension_index i1 = * (const extension_index *) p1; 7043464ebd5Sriastradh extension_index i2 = * (const extension_index *) p2; 7053464ebd5Sriastradh const struct extension *e1 = &extension_table[i1]; 7063464ebd5Sriastradh const struct extension *e2 = &extension_table[i2]; 7073464ebd5Sriastradh int res; 7087117f1b4Smrg 7093464ebd5Sriastradh res = (int)e1->year - (int)e2->year; 7103464ebd5Sriastradh 7113464ebd5Sriastradh if (res == 0) { 7123464ebd5Sriastradh res = strcmp(e1->name, e2->name); 7137117f1b4Smrg } 7143464ebd5Sriastradh 7153464ebd5Sriastradh return res; 7167117f1b4Smrg} 7177117f1b4Smrg 7187117f1b4Smrg 7197117f1b4Smrg/** 7207117f1b4Smrg * Construct the GL_EXTENSIONS string. Called the first time that 7217117f1b4Smrg * glGetString(GL_EXTENSIONS) is called. 7227117f1b4Smrg */ 7233464ebd5SriastradhGLubyte* 7243464ebd5Sriastradh_mesa_make_extension_string(struct gl_context *ctx) 7257117f1b4Smrg{ 7263464ebd5Sriastradh /* The extension string. */ 7273464ebd5Sriastradh char *exts = 0; 7283464ebd5Sriastradh /* Length of extension string. */ 7293464ebd5Sriastradh size_t length = 0; 7303464ebd5Sriastradh /* Number of extensions */ 7313464ebd5Sriastradh unsigned count; 7323464ebd5Sriastradh /* Indices of the extensions sorted by year */ 7333464ebd5Sriastradh extension_index *extension_indices; 7343464ebd5Sriastradh /* String of extra extensions. */ 7353464ebd5Sriastradh char *extra_extensions = get_extension_override(ctx); 7363464ebd5Sriastradh GLboolean *base = (GLboolean *) &ctx->Extensions; 7373464ebd5Sriastradh const struct extension *i; 7383464ebd5Sriastradh unsigned j; 7393464ebd5Sriastradh unsigned maxYear = ~0; 740af69d88dSmrg unsigned api_set = (1 << ctx->API); 741af69d88dSmrg if (_mesa_is_gles3(ctx)) 742af69d88dSmrg api_set |= ES3; 7433464ebd5Sriastradh 7443464ebd5Sriastradh /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */ 7453464ebd5Sriastradh { 7463464ebd5Sriastradh const char *env = getenv("MESA_EXTENSION_MAX_YEAR"); 7473464ebd5Sriastradh if (env) { 7483464ebd5Sriastradh maxYear = atoi(env); 7493464ebd5Sriastradh _mesa_debug(ctx, "Note: limiting GL extensions to %u or earlier\n", 7503464ebd5Sriastradh maxYear); 7517117f1b4Smrg } 7527117f1b4Smrg } 7534a49301eSmrg 7543464ebd5Sriastradh /* Compute length of the extension string. */ 7553464ebd5Sriastradh count = 0; 7563464ebd5Sriastradh for (i = extension_table; i->name != 0; ++i) { 7573464ebd5Sriastradh if (base[i->offset] && 7583464ebd5Sriastradh i->year <= maxYear && 759af69d88dSmrg (i->api_set & api_set)) { 7603464ebd5Sriastradh length += strlen(i->name) + 1; /* +1 for space */ 7613464ebd5Sriastradh ++count; 7623464ebd5Sriastradh } 7633464ebd5Sriastradh } 7643464ebd5Sriastradh if (extra_extensions != NULL) 7653464ebd5Sriastradh length += 1 + strlen(extra_extensions); /* +1 for space */ 7664a49301eSmrg 767af69d88dSmrg exts = calloc(ALIGN(length + 1, 4), sizeof(char)); 7683464ebd5Sriastradh if (exts == NULL) { 7693464ebd5Sriastradh free(extra_extensions); 7704a49301eSmrg return NULL; 7717117f1b4Smrg } 7727117f1b4Smrg 7733464ebd5Sriastradh extension_indices = malloc(count * sizeof(extension_index)); 7743464ebd5Sriastradh if (extension_indices == NULL) { 7753464ebd5Sriastradh free(exts); 7763464ebd5Sriastradh free(extra_extensions); 7773464ebd5Sriastradh return NULL; 7783464ebd5Sriastradh } 7797117f1b4Smrg 780af69d88dSmrg /* Sort extensions in chronological order because certain old applications 781af69d88dSmrg * (e.g., Quake3 demo) store the extension list in a static size buffer so 782af69d88dSmrg * chronologically order ensure that the extensions that such applications 783af69d88dSmrg * expect will fit into that buffer. 7843464ebd5Sriastradh */ 7853464ebd5Sriastradh j = 0; 7863464ebd5Sriastradh for (i = extension_table; i->name != 0; ++i) { 7873464ebd5Sriastradh if (base[i->offset] && 7883464ebd5Sriastradh i->year <= maxYear && 789af69d88dSmrg (i->api_set & api_set)) { 7903464ebd5Sriastradh extension_indices[j++] = i - extension_table; 7913464ebd5Sriastradh } 7923464ebd5Sriastradh } 7933464ebd5Sriastradh assert(j == count); 794af69d88dSmrg qsort(extension_indices, count, 795af69d88dSmrg sizeof *extension_indices, extension_compare); 7963464ebd5Sriastradh 7973464ebd5Sriastradh /* Build the extension string.*/ 7983464ebd5Sriastradh for (j = 0; j < count; ++j) { 7993464ebd5Sriastradh i = &extension_table[extension_indices[j]]; 800af69d88dSmrg assert(base[i->offset] && (i->api_set & api_set)); 8013464ebd5Sriastradh strcat(exts, i->name); 8023464ebd5Sriastradh strcat(exts, " "); 8033464ebd5Sriastradh } 8043464ebd5Sriastradh free(extension_indices); 8053464ebd5Sriastradh if (extra_extensions != 0) { 8063464ebd5Sriastradh strcat(exts, extra_extensions); 8073464ebd5Sriastradh free(extra_extensions); 8084a49301eSmrg } 8094a49301eSmrg 8103464ebd5Sriastradh return (GLubyte *) exts; 8117117f1b4Smrg} 812cdc920a0Smrg 813cdc920a0Smrg/** 814cdc920a0Smrg * Return number of enabled extensions. 815cdc920a0Smrg */ 816cdc920a0SmrgGLuint 8173464ebd5Sriastradh_mesa_get_extension_count(struct gl_context *ctx) 818cdc920a0Smrg{ 8193464ebd5Sriastradh GLboolean *base; 8203464ebd5Sriastradh const struct extension *i; 821af69d88dSmrg unsigned api_set = (1 << ctx->API); 822af69d88dSmrg if (_mesa_is_gles3(ctx)) 823af69d88dSmrg api_set |= ES3; 824cdc920a0Smrg 825cdc920a0Smrg /* only count once */ 8263464ebd5Sriastradh if (ctx->Extensions.Count != 0) 8273464ebd5Sriastradh return ctx->Extensions.Count; 8283464ebd5Sriastradh 8293464ebd5Sriastradh base = (GLboolean *) &ctx->Extensions; 8303464ebd5Sriastradh for (i = extension_table; i->name != 0; ++i) { 831af69d88dSmrg if (base[i->offset] && (i->api_set & api_set)) { 8323464ebd5Sriastradh ctx->Extensions.Count++; 833cdc920a0Smrg } 834cdc920a0Smrg } 835cdc920a0Smrg return ctx->Extensions.Count; 836cdc920a0Smrg} 837cdc920a0Smrg 838cdc920a0Smrg/** 839cdc920a0Smrg * Return name of i-th enabled extension 840cdc920a0Smrg */ 841cdc920a0Smrgconst GLubyte * 8423464ebd5Sriastradh_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) 843cdc920a0Smrg{ 8443464ebd5Sriastradh const GLboolean *base; 8453464ebd5Sriastradh size_t n; 8463464ebd5Sriastradh const struct extension *i; 847af69d88dSmrg unsigned api_set = (1 << ctx->API); 848af69d88dSmrg if (_mesa_is_gles3(ctx)) 849af69d88dSmrg api_set |= ES3; 850cdc920a0Smrg 8513464ebd5Sriastradh base = (GLboolean*) &ctx->Extensions; 8523464ebd5Sriastradh n = 0; 8533464ebd5Sriastradh for (i = extension_table; i->name != 0; ++i) { 854af69d88dSmrg if (base[i->offset] && (i->api_set & api_set)) { 855af69d88dSmrg if (n == index) 856af69d88dSmrg return (const GLubyte*) i->name; 857af69d88dSmrg else 858af69d88dSmrg ++n; 859cdc920a0Smrg } 860cdc920a0Smrg } 861cdc920a0Smrg 862cdc920a0Smrg return NULL; 863cdc920a0Smrg} 864