extensions.c revision 3464ebd5
17117f1b4Smrg/*
27117f1b4Smrg * Mesa 3-D graphics library
34a49301eSmrg * Version:  7.6
47117f1b4Smrg *
5c1f859d4Smrg * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
64a49301eSmrg * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
77117f1b4Smrg *
87117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
97117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
107117f1b4Smrg * to deal in the Software without restriction, including without limitation
117117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
127117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
137117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
147117f1b4Smrg *
157117f1b4Smrg * The above copyright notice and this permission notice shall be included
167117f1b4Smrg * in all copies or substantial portions of the Software.
177117f1b4Smrg *
187117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
197117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
207117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
217117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
227117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
237117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR 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"
373464ebd5Sriastradh#include "mfeatures.h"
387117f1b4Smrg#include "mtypes.h"
397117f1b4Smrg
403464ebd5Sriastradhenum {
413464ebd5Sriastradh   DISABLE = 0,
423464ebd5Sriastradh   GL  = 1 << API_OPENGL,
433464ebd5Sriastradh   ES1 = 1 << API_OPENGLES,
443464ebd5Sriastradh   ES2 = 1 << API_OPENGLES2,
453464ebd5Sriastradh};
467117f1b4Smrg
473464ebd5Sriastradh/**
483464ebd5Sriastradh * \brief An element of the \c extension_table.
493464ebd5Sriastradh */
503464ebd5Sriastradhstruct extension {
513464ebd5Sriastradh   /** Name of extension, such as "GL_ARB_depth_clamp". */
523464ebd5Sriastradh   const char *name;
537117f1b4Smrg
543464ebd5Sriastradh   /** Offset (in bytes) of the corresponding member in struct gl_extensions. */
553464ebd5Sriastradh   size_t offset;
567117f1b4Smrg
573464ebd5Sriastradh   /** Set of API's in which the extension exists, as a bitset. */
583464ebd5Sriastradh   uint8_t api_set;
593464ebd5Sriastradh
603464ebd5Sriastradh   /** Year the extension was proposed or approved.  Used to sort the
613464ebd5Sriastradh    * extension string chronologically. */
623464ebd5Sriastradh   uint16_t year;
633464ebd5Sriastradh};
643464ebd5Sriastradh
653464ebd5Sriastradh
663464ebd5Sriastradh/**
673464ebd5Sriastradh * Given a member \c x of struct gl_extensions, return offset of
683464ebd5Sriastradh * \c x in bytes.
693464ebd5Sriastradh */
703464ebd5Sriastradh#define o(x) offsetof(struct gl_extensions, x)
713464ebd5Sriastradh
723464ebd5Sriastradh
733464ebd5Sriastradh/**
743464ebd5Sriastradh * \brief Table of supported OpenGL extensions for all API's.
753464ebd5Sriastradh *
767117f1b4Smrg * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions.
777117f1b4Smrg */
783464ebd5Sriastradhstatic const struct extension extension_table[] = {
793464ebd5Sriastradh   /* ARB Extensions */
803464ebd5Sriastradh   { "GL_ARB_ES2_compatibility",                   o(ARB_ES2_compatibility),                   GL,             2009 },
813464ebd5Sriastradh   { "GL_ARB_blend_func_extended",                 o(ARB_blend_func_extended),                 GL,             2009 },
823464ebd5Sriastradh   { "GL_ARB_color_buffer_float",                  o(ARB_color_buffer_float),                  GL,             2004 },
833464ebd5Sriastradh   { "GL_ARB_copy_buffer",                         o(ARB_copy_buffer),                         GL,             2008 },
843464ebd5Sriastradh   { "GL_ARB_depth_buffer_float",                  o(ARB_depth_buffer_float),                  GL,             2008 },
853464ebd5Sriastradh   { "GL_ARB_depth_clamp",                         o(ARB_depth_clamp),                         GL,             2003 },
863464ebd5Sriastradh   { "GL_ARB_depth_texture",                       o(ARB_depth_texture),                       GL,             2001 },
873464ebd5Sriastradh   { "GL_ARB_draw_buffers",                        o(ARB_draw_buffers),                        GL,             2002 },
883464ebd5Sriastradh   { "GL_ARB_draw_buffers_blend",                  o(ARB_draw_buffers_blend),                  GL,             2009 },
893464ebd5Sriastradh   { "GL_ARB_draw_elements_base_vertex",           o(ARB_draw_elements_base_vertex),           GL,             2009 },
903464ebd5Sriastradh   { "GL_ARB_draw_instanced",                      o(ARB_draw_instanced),                      GL,             2008 },
913464ebd5Sriastradh   { "GL_ARB_explicit_attrib_location",            o(ARB_explicit_attrib_location),            GL,             2009 },
923464ebd5Sriastradh   { "GL_ARB_fragment_coord_conventions",          o(ARB_fragment_coord_conventions),          GL,             2009 },
933464ebd5Sriastradh   { "GL_ARB_fragment_program",                    o(ARB_fragment_program),                    GL,             2002 },
943464ebd5Sriastradh   { "GL_ARB_fragment_program_shadow",             o(ARB_fragment_program_shadow),             GL,             2003 },
953464ebd5Sriastradh   { "GL_ARB_fragment_shader",                     o(ARB_fragment_shader),                     GL,             2002 },
963464ebd5Sriastradh   { "GL_ARB_framebuffer_object",                  o(ARB_framebuffer_object),                  GL,             2005 },
973464ebd5Sriastradh   { "GL_ARB_framebuffer_sRGB",                    o(EXT_framebuffer_sRGB),                    GL,             1998 },
983464ebd5Sriastradh   { "GL_ARB_half_float_pixel",                    o(ARB_half_float_pixel),                    GL,             2003 },
993464ebd5Sriastradh   { "GL_ARB_half_float_vertex",                   o(ARB_half_float_vertex),                   GL,             2008 },
1003464ebd5Sriastradh   { "GL_ARB_instanced_arrays",                    o(ARB_instanced_arrays),                    GL,             2008 },
1013464ebd5Sriastradh   { "GL_ARB_map_buffer_range",                    o(ARB_map_buffer_range),                    GL,             2008 },
1023464ebd5Sriastradh   { "GL_ARB_multisample",                         o(ARB_multisample),                         GL,             1994 },
1033464ebd5Sriastradh   { "GL_ARB_multitexture",                        o(ARB_multitexture),                        GL,             1998 },
1043464ebd5Sriastradh   { "GL_ARB_occlusion_query2",                    o(ARB_occlusion_query2),                    GL,             2003 },
1053464ebd5Sriastradh   { "GL_ARB_occlusion_query",                     o(ARB_occlusion_query),                     GL,             2001 },
1063464ebd5Sriastradh   { "GL_ARB_pixel_buffer_object",                 o(EXT_pixel_buffer_object),                 GL,             2004 },
1073464ebd5Sriastradh   { "GL_ARB_point_parameters",                    o(EXT_point_parameters),                    GL,             1997 },
1083464ebd5Sriastradh   { "GL_ARB_point_sprite",                        o(ARB_point_sprite),                        GL,             2003 },
1093464ebd5Sriastradh   { "GL_ARB_provoking_vertex",                    o(EXT_provoking_vertex),                    GL,             2009 },
1103464ebd5Sriastradh   { "GL_ARB_robustness",                          o(dummy_true),                              GL,             2010 },
1113464ebd5Sriastradh   { "GL_ARB_sampler_objects",                     o(ARB_sampler_objects),                     GL,             2009 },
1123464ebd5Sriastradh   { "GL_ARB_seamless_cube_map",                   o(ARB_seamless_cube_map),                   GL,             2009 },
1133464ebd5Sriastradh   { "GL_ARB_shader_objects",                      o(ARB_shader_objects),                      GL,             2002 },
1143464ebd5Sriastradh   { "GL_ARB_shader_stencil_export",               o(ARB_shader_stencil_export),               GL,             2009 },
1153464ebd5Sriastradh   { "GL_ARB_shader_texture_lod",                  o(ARB_shader_texture_lod),                  GL,             2009 },
1163464ebd5Sriastradh   { "GL_ARB_shading_language_100",                o(ARB_shading_language_100),                GL,             2003 },
1173464ebd5Sriastradh   { "GL_ARB_shadow_ambient",                      o(ARB_shadow_ambient),                      GL,             2001 },
1183464ebd5Sriastradh   { "GL_ARB_shadow",                              o(ARB_shadow),                              GL,             2001 },
1193464ebd5Sriastradh   { "GL_ARB_sync",                                o(ARB_sync),                                GL,             2003 },
1203464ebd5Sriastradh   { "GL_ARB_texture_border_clamp",                o(ARB_texture_border_clamp),                GL,             2000 },
1213464ebd5Sriastradh   { "GL_ARB_texture_buffer_object",               o(ARB_texture_buffer_object),               GL,             2008 },
1223464ebd5Sriastradh   { "GL_ARB_texture_compression",                 o(ARB_texture_compression),                 GL,             2000 },
1233464ebd5Sriastradh   { "GL_ARB_texture_compression_rgtc",            o(ARB_texture_compression_rgtc),            GL,             2004 },
1243464ebd5Sriastradh   { "GL_ARB_texture_cube_map",                    o(ARB_texture_cube_map),                    GL,             1999 },
1253464ebd5Sriastradh   { "GL_ARB_texture_env_add",                     o(EXT_texture_env_add),                     GL,             1999 },
1263464ebd5Sriastradh   { "GL_ARB_texture_env_combine",                 o(ARB_texture_env_combine),                 GL,             2001 },
1273464ebd5Sriastradh   { "GL_ARB_texture_env_crossbar",                o(ARB_texture_env_crossbar),                GL,             2001 },
1283464ebd5Sriastradh   { "GL_ARB_texture_env_dot3",                    o(ARB_texture_env_dot3),                    GL,             2001 },
1293464ebd5Sriastradh   { "GL_ARB_texture_float",                       o(ARB_texture_float),                       GL,             2004 },
1303464ebd5Sriastradh   { "GL_ARB_texture_mirrored_repeat",             o(ARB_texture_mirrored_repeat),             GL,             2001 },
1313464ebd5Sriastradh   { "GL_ARB_texture_multisample",                 o(ARB_texture_multisample),                 GL,             2009 },
1323464ebd5Sriastradh   { "GL_ARB_texture_non_power_of_two",            o(ARB_texture_non_power_of_two),            GL,             2003 },
1333464ebd5Sriastradh   { "GL_ARB_texture_rectangle",                   o(NV_texture_rectangle),                    GL,             2004 },
1343464ebd5Sriastradh   { "GL_ARB_texture_rgb10_a2ui",                  o(ARB_texture_rgb10_a2ui),                  GL,             2009 },
1353464ebd5Sriastradh   { "GL_ARB_texture_rg",                          o(ARB_texture_rg),                          GL,             2008 },
1363464ebd5Sriastradh   { "GL_ARB_texture_swizzle",                     o(EXT_texture_swizzle),                     GL,             2008 },
1373464ebd5Sriastradh   { "GL_ARB_transform_feedback2",                 o(ARB_transform_feedback2),                 GL,             2010 },
1383464ebd5Sriastradh   { "GL_ARB_transpose_matrix",                    o(ARB_transpose_matrix),                    GL,             1999 },
1393464ebd5Sriastradh   { "GL_ARB_uniform_buffer_object",               o(ARB_uniform_buffer_object),               GL,             2002 },
1403464ebd5Sriastradh   { "GL_ARB_vertex_array_bgra",                   o(EXT_vertex_array_bgra),                   GL,             2008 },
1413464ebd5Sriastradh   { "GL_ARB_vertex_array_object",                 o(ARB_vertex_array_object),                 GL,             2006 },
1423464ebd5Sriastradh   { "GL_ARB_vertex_buffer_object",                o(ARB_vertex_buffer_object),                GL,             2003 },
1433464ebd5Sriastradh   { "GL_ARB_vertex_program",                      o(ARB_vertex_program),                      GL,             2002 },
1443464ebd5Sriastradh   { "GL_ARB_vertex_shader",                       o(ARB_vertex_shader),                       GL,             2002 },
1453464ebd5Sriastradh   { "GL_ARB_vertex_type_2_10_10_10_rev",          o(ARB_vertex_type_2_10_10_10_rev),          GL,             2009 },
1463464ebd5Sriastradh   { "GL_ARB_window_pos",                          o(ARB_window_pos),                          GL,             2001 },
1473464ebd5Sriastradh   /* EXT extensions */
1483464ebd5Sriastradh   { "GL_EXT_abgr",                                o(EXT_abgr),                                GL,             1995 },
1493464ebd5Sriastradh   { "GL_EXT_bgra",                                o(EXT_bgra),                                GL,             1995 },
1503464ebd5Sriastradh   { "GL_EXT_blend_color",                         o(EXT_blend_color),                         GL,             1995 },
1513464ebd5Sriastradh   { "GL_EXT_blend_equation_separate",             o(EXT_blend_equation_separate),             GL,             2003 },
1523464ebd5Sriastradh   { "GL_EXT_blend_func_separate",                 o(EXT_blend_func_separate),                 GL,             1999 },
1533464ebd5Sriastradh   { "GL_EXT_blend_logic_op",                      o(EXT_blend_logic_op),                      GL,             1995 },
1543464ebd5Sriastradh   { "GL_EXT_blend_minmax",                        o(EXT_blend_minmax),                        GL | ES1 | ES2, 1995 },
1553464ebd5Sriastradh   { "GL_EXT_blend_subtract",                      o(EXT_blend_subtract),                      GL,             1995 },
1563464ebd5Sriastradh   { "GL_EXT_clip_volume_hint",                    o(EXT_clip_volume_hint),                    GL,             1996 },
1573464ebd5Sriastradh   { "GL_EXT_compiled_vertex_array",               o(EXT_compiled_vertex_array),               GL,             1996 },
1583464ebd5Sriastradh   { "GL_EXT_copy_texture",                        o(EXT_copy_texture),                        GL,             1995 },
1593464ebd5Sriastradh   { "GL_EXT_depth_bounds_test",                   o(EXT_depth_bounds_test),                   GL,             2002 },
1603464ebd5Sriastradh   { "GL_EXT_draw_buffers2",                       o(EXT_draw_buffers2),                       GL,             2006 },
1613464ebd5Sriastradh   { "GL_EXT_draw_instanced",                      o(ARB_draw_instanced),                      GL,             2006 },
1623464ebd5Sriastradh   { "GL_EXT_draw_range_elements",                 o(EXT_draw_range_elements),                 GL,             1997 },
1633464ebd5Sriastradh   { "GL_EXT_fog_coord",                           o(EXT_fog_coord),                           GL,             1999 },
1643464ebd5Sriastradh   { "GL_EXT_framebuffer_blit",                    o(EXT_framebuffer_blit),                    GL,             2005 },
1653464ebd5Sriastradh   { "GL_EXT_framebuffer_multisample",             o(EXT_framebuffer_multisample),             GL,             2005 },
1663464ebd5Sriastradh   { "GL_EXT_framebuffer_object",                  o(EXT_framebuffer_object),                  GL,             2000 },
1673464ebd5Sriastradh   { "GL_EXT_framebuffer_sRGB",                    o(EXT_framebuffer_sRGB),                    GL,             1998 },
1683464ebd5Sriastradh   { "GL_EXT_gpu_program_parameters",              o(EXT_gpu_program_parameters),              GL,             2006 },
1693464ebd5Sriastradh   { "GL_EXT_gpu_shader4",                         o(EXT_gpu_shader4),                         GL,             2006 },
1703464ebd5Sriastradh   { "GL_EXT_multi_draw_arrays",                   o(EXT_multi_draw_arrays),                   GL | ES1 | ES2, 1999 },
1713464ebd5Sriastradh   { "GL_EXT_packed_depth_stencil",                o(EXT_packed_depth_stencil),                GL,             2005 },
1723464ebd5Sriastradh   { "GL_EXT_packed_float",                        o(EXT_packed_float),                        GL,             2004 },
1733464ebd5Sriastradh   { "GL_EXT_packed_pixels",                       o(EXT_packed_pixels),                       GL,             1997 },
1743464ebd5Sriastradh   { "GL_EXT_paletted_texture",                    o(EXT_paletted_texture),                    GL,             1995 },
1753464ebd5Sriastradh   { "GL_EXT_pixel_buffer_object",                 o(EXT_pixel_buffer_object),                 GL,             2004 },
1763464ebd5Sriastradh   { "GL_EXT_point_parameters",                    o(EXT_point_parameters),                    GL,             1997 },
1773464ebd5Sriastradh   { "GL_EXT_polygon_offset",                      o(EXT_polygon_offset),                      GL,             1995 },
1783464ebd5Sriastradh   { "GL_EXT_provoking_vertex",                    o(EXT_provoking_vertex),                    GL,             2009 },
1793464ebd5Sriastradh   { "GL_EXT_rescale_normal",                      o(EXT_rescale_normal),                      GL,             1997 },
1803464ebd5Sriastradh   { "GL_EXT_secondary_color",                     o(EXT_secondary_color),                     GL,             1999 },
1813464ebd5Sriastradh   { "GL_EXT_separate_shader_objects",             o(EXT_separate_shader_objects),             GL,             2008 },
1823464ebd5Sriastradh   { "GL_EXT_separate_specular_color",             o(EXT_separate_specular_color),             GL,             1997 },
1833464ebd5Sriastradh   { "GL_EXT_shadow_funcs",                        o(EXT_shadow_funcs),                        GL,             2002 },
1843464ebd5Sriastradh   { "GL_EXT_shared_texture_palette",              o(EXT_shared_texture_palette),              GL,             2000 },
1853464ebd5Sriastradh   { "GL_EXT_stencil_two_side",                    o(EXT_stencil_two_side),                    GL,             2001 },
1863464ebd5Sriastradh   { "GL_EXT_stencil_wrap",                        o(EXT_stencil_wrap),                        GL,             2002 },
1873464ebd5Sriastradh   { "GL_EXT_subtexture",                          o(EXT_subtexture),                          GL,             1995 },
1883464ebd5Sriastradh   { "GL_EXT_texture3D",                           o(EXT_texture3D),                           GL,             1996 },
1893464ebd5Sriastradh   { "GL_EXT_texture_array",                       o(EXT_texture_array),                       GL,             2006 },
1903464ebd5Sriastradh   { "GL_EXT_texture_compression_dxt1",            o(EXT_texture_compression_s3tc),            GL | ES1 | ES2, 2004 },
1913464ebd5Sriastradh   { "GL_EXT_texture_compression_latc",            o(EXT_texture_compression_latc),            GL,             2006 },
1923464ebd5Sriastradh   { "GL_EXT_texture_compression_rgtc",            o(ARB_texture_compression_rgtc),            GL,             2004 },
1933464ebd5Sriastradh   { "GL_EXT_texture_compression_s3tc",            o(EXT_texture_compression_s3tc),            GL,             2000 },
1943464ebd5Sriastradh   { "GL_EXT_texture_cube_map",                    o(ARB_texture_cube_map),                    GL,             2001 },
1953464ebd5Sriastradh   { "GL_EXT_texture_edge_clamp",                  o(SGIS_texture_edge_clamp),                 GL,             1997 },
1963464ebd5Sriastradh   { "GL_EXT_texture_env_add",                     o(EXT_texture_env_add),                     GL,             1999 },
1973464ebd5Sriastradh   { "GL_EXT_texture_env_combine",                 o(EXT_texture_env_combine),                 GL,             2006 },
1983464ebd5Sriastradh   { "GL_EXT_texture_env_dot3",                    o(EXT_texture_env_dot3),                    GL,             2000 },
1993464ebd5Sriastradh   { "GL_EXT_texture_filter_anisotropic",          o(EXT_texture_filter_anisotropic),          GL | ES1 | ES2, 1999 },
2003464ebd5Sriastradh   { "GL_EXT_texture_format_BGRA8888",             o(EXT_texture_format_BGRA8888),                  ES1 | ES2, 2009 },
2013464ebd5Sriastradh   { "GL_EXT_texture_integer",                     o(EXT_texture_integer),                     GL,             2006 },
2023464ebd5Sriastradh   { "GL_EXT_texture_lod_bias",                    o(EXT_texture_lod_bias),                    GL | ES1,       1999 },
2033464ebd5Sriastradh   { "GL_EXT_texture_mirror_clamp",                o(EXT_texture_mirror_clamp),                GL,             2004 },
2043464ebd5Sriastradh   { "GL_EXT_texture_object",                      o(EXT_texture_object),                      GL,             1995 },
2053464ebd5Sriastradh   { "GL_EXT_texture",                             o(EXT_texture),                             GL,             1996 },
2063464ebd5Sriastradh   { "GL_EXT_texture_rectangle",                   o(NV_texture_rectangle),                    GL,             2004 },
2073464ebd5Sriastradh   { "GL_EXT_texture_shared_exponent",             o(EXT_texture_shared_exponent),             GL,             2004 },
2083464ebd5Sriastradh   { "GL_EXT_texture_snorm",                       o(EXT_texture_snorm),                       GL,             2009 },
2093464ebd5Sriastradh   { "GL_EXT_texture_sRGB",                        o(EXT_texture_sRGB),                        GL,             2004 },
2103464ebd5Sriastradh   { "GL_EXT_texture_sRGB_decode",                 o(EXT_texture_sRGB_decode),                        GL,      2006 },
2113464ebd5Sriastradh   { "GL_EXT_texture_swizzle",                     o(EXT_texture_swizzle),                     GL,             2008 },
2123464ebd5Sriastradh   { "GL_EXT_texture_type_2_10_10_10_REV",         o(dummy_true),                                         ES2, 2008 },
2133464ebd5Sriastradh   { "GL_EXT_timer_query",                         o(EXT_timer_query),                         GL,             2006 },
2143464ebd5Sriastradh   { "GL_EXT_transform_feedback",                  o(EXT_transform_feedback),                  GL,             2011 },
2153464ebd5Sriastradh   { "GL_EXT_vertex_array_bgra",                   o(EXT_vertex_array_bgra),                   GL,             2008 },
2163464ebd5Sriastradh   { "GL_EXT_vertex_array",                        o(EXT_vertex_array),                        GL,             1995 },
2173464ebd5Sriastradh   { "GL_EXT_vertex_array_set",                    o(EXT_vertex_array_set),                    GL,             1997 },
2183464ebd5Sriastradh
2193464ebd5Sriastradh   /* OES extensions */
2203464ebd5Sriastradh   { "GL_OES_blend_equation_separate",             o(EXT_blend_equation_separate),                  ES1,       2009 },
2213464ebd5Sriastradh   { "GL_OES_blend_func_separate",                 o(EXT_blend_func_separate),                      ES1,       2009 },
2223464ebd5Sriastradh   { "GL_OES_blend_subtract",                      o(EXT_blend_subtract),                           ES1,       2009 },
2233464ebd5Sriastradh   { "GL_OES_byte_coordinates",                    o(dummy_true),                                   ES1,       2002 },
2243464ebd5Sriastradh   { "GL_OES_compressed_paletted_texture",         o(dummy_true),                                   ES1,       2003 },
2253464ebd5Sriastradh   { "GL_OES_depth24",                             o(EXT_framebuffer_object),                       ES1 | ES2, 2005 },
2263464ebd5Sriastradh   { "GL_OES_depth32",                             o(dummy_false),                     DISABLE,                2005 },
2273464ebd5Sriastradh   { "GL_OES_depth_texture",                       o(ARB_depth_texture),                                  ES2, 2006 },
228cdc920a0Smrg#if FEATURE_OES_draw_texture
2293464ebd5Sriastradh   { "GL_OES_draw_texture",                        o(OES_draw_texture),                             ES1 | ES2, 2004 },
2303464ebd5Sriastradh#endif
2313464ebd5Sriastradh#if FEATURE_OES_EGL_image
2323464ebd5Sriastradh   /*  FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */
2333464ebd5Sriastradh   { "GL_OES_EGL_image",                           o(OES_EGL_image),                           GL | ES1 | ES2, 2006 },
2343464ebd5Sriastradh#endif
2353464ebd5Sriastradh   { "GL_OES_element_index_uint",                  o(EXT_vertex_array),                             ES1 | ES2, 2005 },
2363464ebd5Sriastradh   { "GL_OES_fbo_render_mipmap",                   o(EXT_framebuffer_object),                       ES1 | ES2, 2005 },
2373464ebd5Sriastradh   { "GL_OES_fixed_point",                         o(dummy_true),                                   ES1,       2002 },
2383464ebd5Sriastradh   { "GL_OES_framebuffer_object",                  o(EXT_framebuffer_object),                       ES1,       2005 },
2393464ebd5Sriastradh   { "GL_OES_mapbuffer",                           o(ARB_vertex_buffer_object),                     ES1 | ES2, 2005 },
2403464ebd5Sriastradh   { "GL_OES_matrix_get",                          o(dummy_true),                                   ES1,       2004 },
2413464ebd5Sriastradh   { "GL_OES_packed_depth_stencil",                o(EXT_packed_depth_stencil),                     ES1 | ES2, 2007 },
2423464ebd5Sriastradh   { "GL_OES_point_size_array",                    o(dummy_true),                                   ES1,       2004 },
2433464ebd5Sriastradh   { "GL_OES_point_sprite",                        o(ARB_point_sprite),                             ES1,       2004 },
2443464ebd5Sriastradh   { "GL_OES_query_matrix",                        o(dummy_true),                                   ES1,       2003 },
2453464ebd5Sriastradh   { "GL_OES_read_format",                         o(OES_read_format),                         GL | ES1,       2003 },
2463464ebd5Sriastradh   { "GL_OES_rgb8_rgba8",                          o(EXT_framebuffer_object),                       ES1 | ES2, 2005 },
2473464ebd5Sriastradh   { "GL_OES_single_precision",                    o(dummy_true),                                   ES1,       2003 },
2483464ebd5Sriastradh   { "GL_OES_standard_derivatives",                o(OES_standard_derivatives),                           ES2, 2005 },
2493464ebd5Sriastradh   { "GL_OES_stencil1",                            o(dummy_false),                     DISABLE,                2005 },
2503464ebd5Sriastradh   { "GL_OES_stencil4",                            o(dummy_false),                     DISABLE,                2005 },
2513464ebd5Sriastradh   { "GL_OES_stencil8",                            o(EXT_framebuffer_object),                       ES1 | ES2, 2005 },
2523464ebd5Sriastradh   { "GL_OES_stencil_wrap",                        o(EXT_stencil_wrap),                             ES1,       2002 },
2533464ebd5Sriastradh   { "GL_OES_texture_3D",                          o(EXT_texture3D),                                      ES2, 2005 },
2543464ebd5Sriastradh   { "GL_OES_texture_cube_map",                    o(ARB_texture_cube_map),                         ES1,       2007 },
2553464ebd5Sriastradh   { "GL_OES_texture_env_crossbar",                o(ARB_texture_env_crossbar),                     ES1,       2005 },
2563464ebd5Sriastradh   { "GL_OES_texture_mirrored_repeat",             o(ARB_texture_mirrored_repeat),                  ES1,       2005 },
2573464ebd5Sriastradh   { "GL_OES_texture_npot",                        o(ARB_texture_non_power_of_two),                       ES2, 2005 },
2583464ebd5Sriastradh
2593464ebd5Sriastradh   /* Vendor extensions */
2603464ebd5Sriastradh   { "GL_3DFX_texture_compression_FXT1",           o(TDFX_texture_compression_FXT1),           GL,             1999 },
2613464ebd5Sriastradh   { "GL_AMD_conservative_depth",                  o(AMD_conservative_depth),                  GL,             2009 },
2623464ebd5Sriastradh   { "GL_AMD_draw_buffers_blend",                  o(ARB_draw_buffers_blend),                  GL,             2009 },
2633464ebd5Sriastradh   { "GL_AMD_seamless_cubemap_per_texture",        o(AMD_seamless_cubemap_per_texture),        GL,             2009 },
2643464ebd5Sriastradh   { "GL_AMD_shader_stencil_export",               o(ARB_shader_stencil_export),               GL,             2009 },
2653464ebd5Sriastradh   { "GL_APPLE_client_storage",                    o(APPLE_client_storage),                    GL,             2002 },
2663464ebd5Sriastradh   { "GL_APPLE_object_purgeable",                  o(APPLE_object_purgeable),                  GL,             2006 },
2673464ebd5Sriastradh   { "GL_APPLE_packed_pixels",                     o(APPLE_packed_pixels),                     GL,             2002 },
2683464ebd5Sriastradh   { "GL_APPLE_vertex_array_object",               o(APPLE_vertex_array_object),               GL,             2002 },
2693464ebd5Sriastradh   { "GL_ATI_blend_equation_separate",             o(EXT_blend_equation_separate),             GL,             2003 },
2703464ebd5Sriastradh   { "GL_ATI_draw_buffers",                        o(ARB_draw_buffers),                        GL,             2002 },
2713464ebd5Sriastradh   { "GL_ATI_envmap_bumpmap",                      o(ATI_envmap_bumpmap),                      GL,             2001 },
2723464ebd5Sriastradh   { "GL_ATI_fragment_shader",                     o(ATI_fragment_shader),                     GL,             2001 },
2733464ebd5Sriastradh   { "GL_ATI_separate_stencil",                    o(ATI_separate_stencil),                    GL,             2006 },
2743464ebd5Sriastradh   { "GL_ATI_texture_compression_3dc",             o(ATI_texture_compression_3dc),             GL,             2004 },
2753464ebd5Sriastradh   { "GL_ATI_texture_env_combine3",                o(ATI_texture_env_combine3),                GL,             2002 },
2763464ebd5Sriastradh   { "GL_ATI_texture_float",                       o(ARB_texture_float),                       GL,             2002 },
2773464ebd5Sriastradh   { "GL_ATI_texture_mirror_once",                 o(ATI_texture_mirror_once),                 GL,             2006 },
2783464ebd5Sriastradh   { "GL_IBM_multimode_draw_arrays",               o(IBM_multimode_draw_arrays),               GL,             1998 },
2793464ebd5Sriastradh   { "GL_IBM_rasterpos_clip",                      o(IBM_rasterpos_clip),                      GL,             1996 },
2803464ebd5Sriastradh   { "GL_IBM_texture_mirrored_repeat",             o(ARB_texture_mirrored_repeat),             GL,             1998 },
2813464ebd5Sriastradh   { "GL_INGR_blend_func_separate",                o(EXT_blend_func_separate),                 GL,             1999 },
2823464ebd5Sriastradh   { "GL_MESA_pack_invert",                        o(MESA_pack_invert),                        GL,             2002 },
2833464ebd5Sriastradh   { "GL_MESA_resize_buffers",                     o(MESA_resize_buffers),                     GL,             1999 },
2843464ebd5Sriastradh   { "GL_MESA_texture_array",                      o(MESA_texture_array),                      GL,             2007 },
2853464ebd5Sriastradh   { "GL_MESA_texture_signed_rgba",                o(EXT_texture_snorm),                       GL,             2009 },
2863464ebd5Sriastradh   { "GL_MESA_window_pos",                         o(ARB_window_pos),                          GL,             2000 },
2873464ebd5Sriastradh   { "GL_MESA_ycbcr_texture",                      o(MESA_ycbcr_texture),                      GL,             2002 },
2883464ebd5Sriastradh   { "GL_NV_blend_square",                         o(NV_blend_square),                         GL,             1999 },
2893464ebd5Sriastradh   { "GL_NV_conditional_render",                   o(NV_conditional_render),                   GL,             2008 },
2903464ebd5Sriastradh   { "GL_NV_depth_clamp",                          o(ARB_depth_clamp),                         GL,             2001 },
2913464ebd5Sriastradh   { "GL_NV_fragment_program",                     o(NV_fragment_program),                     GL,             2001 },
2923464ebd5Sriastradh   { "GL_NV_fragment_program_option",              o(NV_fragment_program_option),              GL,             2005 },
2933464ebd5Sriastradh   { "GL_NV_light_max_exponent",                   o(NV_light_max_exponent),                   GL,             1999 },
2943464ebd5Sriastradh   { "GL_NV_packed_depth_stencil",                 o(EXT_packed_depth_stencil),                GL,             2000 },
2953464ebd5Sriastradh   { "GL_NV_point_sprite",                         o(NV_point_sprite),                         GL,             2001 },
2963464ebd5Sriastradh   { "GL_NV_primitive_restart",                    o(NV_primitive_restart),                    GL,             2002 },
2973464ebd5Sriastradh   { "GL_NV_texgen_reflection",                    o(NV_texgen_reflection),                    GL,             1999 },
2983464ebd5Sriastradh   { "GL_NV_texture_barrier",                      o(NV_texture_barrier),                      GL,             2009 },
2993464ebd5Sriastradh   { "GL_NV_texture_env_combine4",                 o(NV_texture_env_combine4),                 GL,             1999 },
3003464ebd5Sriastradh   { "GL_NV_texture_rectangle",                    o(NV_texture_rectangle),                    GL,             2000 },
3013464ebd5Sriastradh   { "GL_NV_vertex_program1_1",                    o(NV_vertex_program1_1),                    GL,             2001 },
3023464ebd5Sriastradh   { "GL_NV_vertex_program",                       o(NV_vertex_program),                       GL,             2000 },
3033464ebd5Sriastradh   { "GL_S3_s3tc",                                 o(S3_s3tc),                                 GL,             1999 },
3043464ebd5Sriastradh   { "GL_SGIS_generate_mipmap",                    o(SGIS_generate_mipmap),                    GL,             1997 },
3053464ebd5Sriastradh   { "GL_SGIS_texture_border_clamp",               o(ARB_texture_border_clamp),                GL,             1997 },
3063464ebd5Sriastradh   { "GL_SGIS_texture_edge_clamp",                 o(SGIS_texture_edge_clamp),                 GL,             1997 },
3073464ebd5Sriastradh   { "GL_SGIS_texture_lod",                        o(SGIS_texture_lod),                        GL,             1997 },
3083464ebd5Sriastradh   { "GL_SUN_multi_draw_arrays",                   o(EXT_multi_draw_arrays),                   GL,             1999 },
3093464ebd5Sriastradh
3103464ebd5Sriastradh   { 0, 0, 0, 0 },
3117117f1b4Smrg};
3127117f1b4Smrg
3137117f1b4Smrg
3143464ebd5Sriastradh/**
3153464ebd5Sriastradh * Given an extension name, lookup up the corresponding member of struct
3163464ebd5Sriastradh * gl_extensions and return that member's offset (in bytes).  If the name is
3173464ebd5Sriastradh * not found in the \c extension_table, return 0.
3183464ebd5Sriastradh *
3193464ebd5Sriastradh * \param name Name of extension.
3203464ebd5Sriastradh * \return Offset of member in struct gl_extensions.
3213464ebd5Sriastradh */
3223464ebd5Sriastradhstatic size_t
3233464ebd5Sriastradhname_to_offset(const char* name)
3243464ebd5Sriastradh{
3253464ebd5Sriastradh   const struct extension *i;
3263464ebd5Sriastradh
3273464ebd5Sriastradh   if (name == 0)
3283464ebd5Sriastradh      return 0;
3293464ebd5Sriastradh
3303464ebd5Sriastradh   for (i = extension_table; i->name != 0; ++i) {
3313464ebd5Sriastradh      if (strcmp(name, i->name) == 0)
3323464ebd5Sriastradh	 return i->offset;
3333464ebd5Sriastradh   }
3343464ebd5Sriastradh
3353464ebd5Sriastradh   return 0;
3363464ebd5Sriastradh}
3373464ebd5Sriastradh
3383464ebd5Sriastradh
3393464ebd5Sriastradh/**
3403464ebd5Sriastradh * \brief Extensions enabled by default.
3413464ebd5Sriastradh *
3423464ebd5Sriastradh * These extensions are enabled by _mesa_init_extensions().
3433464ebd5Sriastradh *
3443464ebd5Sriastradh * XXX: Should these defaults also apply to GLES?
3453464ebd5Sriastradh */
3463464ebd5Sriastradhstatic const size_t default_extensions[] = {
3473464ebd5Sriastradh   o(ARB_copy_buffer),
3483464ebd5Sriastradh   o(ARB_draw_buffers),
3493464ebd5Sriastradh   o(ARB_multisample),
3503464ebd5Sriastradh   o(ARB_texture_compression),
3513464ebd5Sriastradh   o(ARB_transpose_matrix),
3523464ebd5Sriastradh   o(ARB_vertex_buffer_object),
3533464ebd5Sriastradh   o(ARB_window_pos),
3543464ebd5Sriastradh
3553464ebd5Sriastradh   o(EXT_abgr),
3563464ebd5Sriastradh   o(EXT_bgra),
3573464ebd5Sriastradh   o(EXT_compiled_vertex_array),
3583464ebd5Sriastradh   o(EXT_copy_texture),
3593464ebd5Sriastradh   o(EXT_draw_range_elements),
3603464ebd5Sriastradh   o(EXT_multi_draw_arrays),
3613464ebd5Sriastradh   o(EXT_packed_pixels),
3623464ebd5Sriastradh   o(EXT_polygon_offset),
3633464ebd5Sriastradh   o(EXT_rescale_normal),
3643464ebd5Sriastradh   o(EXT_separate_specular_color),
3653464ebd5Sriastradh   o(EXT_subtexture),
3663464ebd5Sriastradh   o(EXT_texture),
3673464ebd5Sriastradh   o(EXT_texture3D),
3683464ebd5Sriastradh   o(EXT_texture_object),
3693464ebd5Sriastradh   o(EXT_vertex_array),
3703464ebd5Sriastradh
3713464ebd5Sriastradh   o(OES_read_format),
3723464ebd5Sriastradh   o(OES_standard_derivatives),
3733464ebd5Sriastradh
3743464ebd5Sriastradh   /* Vendor Extensions */
3753464ebd5Sriastradh   o(APPLE_packed_pixels),
3763464ebd5Sriastradh   o(IBM_multimode_draw_arrays),
3773464ebd5Sriastradh   o(IBM_rasterpos_clip),
3783464ebd5Sriastradh   o(NV_light_max_exponent),
3793464ebd5Sriastradh   o(NV_texgen_reflection),
3803464ebd5Sriastradh   o(SGIS_generate_mipmap),
3813464ebd5Sriastradh   o(SGIS_texture_edge_clamp),
3823464ebd5Sriastradh   o(SGIS_texture_lod),
3833464ebd5Sriastradh
3843464ebd5Sriastradh   0,
3853464ebd5Sriastradh};
3863464ebd5Sriastradh
3877117f1b4Smrg
3887117f1b4Smrg/**
3897117f1b4Smrg * Enable all extensions suitable for a software-only renderer.
3907117f1b4Smrg * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
3917117f1b4Smrg */
3927117f1b4Smrgvoid
3933464ebd5Sriastradh_mesa_enable_sw_extensions(struct gl_context *ctx)
3947117f1b4Smrg{
3953464ebd5Sriastradh   /*ctx->Extensions.ARB_copy_buffer = GL_TRUE;*/
3964a49301eSmrg   ctx->Extensions.ARB_depth_clamp = GL_TRUE;
3977117f1b4Smrg   ctx->Extensions.ARB_depth_texture = GL_TRUE;
3984a49301eSmrg   /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
3994a49301eSmrg   ctx->Extensions.ARB_draw_elements_base_vertex = GL_TRUE;
4003464ebd5Sriastradh   ctx->Extensions.ARB_draw_instanced = GL_TRUE;
4013464ebd5Sriastradh   ctx->Extensions.ARB_explicit_attrib_location = GL_TRUE;
402cdc920a0Smrg   ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE;
4037117f1b4Smrg#if FEATURE_ARB_fragment_program
4047117f1b4Smrg   ctx->Extensions.ARB_fragment_program = GL_TRUE;
405c1f859d4Smrg   ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
4067117f1b4Smrg#endif
4077117f1b4Smrg#if FEATURE_ARB_fragment_shader
4087117f1b4Smrg   ctx->Extensions.ARB_fragment_shader = GL_TRUE;
4094a49301eSmrg#endif
4104a49301eSmrg#if FEATURE_ARB_framebuffer_object
4114a49301eSmrg   ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
4123464ebd5Sriastradh#endif
4133464ebd5Sriastradh#if FEATURE_ARB_geometry_shader4 && 0
4143464ebd5Sriastradh   /* XXX re-enable when GLSL compiler again supports geometry shaders */
4153464ebd5Sriastradh   ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
4167117f1b4Smrg#endif
4177117f1b4Smrg   ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
418cdc920a0Smrg   ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
4194a49301eSmrg   ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
4207117f1b4Smrg   ctx->Extensions.ARB_multitexture = GL_TRUE;
4214a49301eSmrg#if FEATURE_queryobj
4227117f1b4Smrg   ctx->Extensions.ARB_occlusion_query = GL_TRUE;
4233464ebd5Sriastradh   ctx->Extensions.ARB_occlusion_query2 = GL_TRUE;
4247117f1b4Smrg#endif
4257117f1b4Smrg   ctx->Extensions.ARB_point_sprite = GL_TRUE;
4267117f1b4Smrg#if FEATURE_ARB_shader_objects
4277117f1b4Smrg   ctx->Extensions.ARB_shader_objects = GL_TRUE;
4283464ebd5Sriastradh   ctx->Extensions.EXT_separate_shader_objects = GL_TRUE;
4297117f1b4Smrg#endif
4307117f1b4Smrg#if FEATURE_ARB_shading_language_100
4317117f1b4Smrg   ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
4327117f1b4Smrg#endif
4337117f1b4Smrg   ctx->Extensions.ARB_shadow = GL_TRUE;
4344a49301eSmrg   ctx->Extensions.ARB_shadow_ambient = GL_TRUE;
4357117f1b4Smrg   ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
4367117f1b4Smrg   ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
4377117f1b4Smrg   ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
4387117f1b4Smrg   ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
4397117f1b4Smrg   ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
4407117f1b4Smrg   /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
4417117f1b4Smrg   ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
4427117f1b4Smrg   ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
4433464ebd5Sriastradh   ctx->Extensions.ARB_texture_rg = GL_TRUE;
4443464ebd5Sriastradh   ctx->Extensions.ARB_texture_compression_rgtc = GL_TRUE;
4454a49301eSmrg   ctx->Extensions.ARB_vertex_array_object = GL_TRUE;
4467117f1b4Smrg#if FEATURE_ARB_vertex_program
4477117f1b4Smrg   ctx->Extensions.ARB_vertex_program = GL_TRUE;
4487117f1b4Smrg#endif
4497117f1b4Smrg#if FEATURE_ARB_vertex_shader
4507117f1b4Smrg   ctx->Extensions.ARB_vertex_shader = GL_TRUE;
4517117f1b4Smrg#endif
4527117f1b4Smrg#if FEATURE_ARB_vertex_buffer_object
4534a49301eSmrg   /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
4544a49301eSmrg#endif
4554a49301eSmrg#if FEATURE_ARB_sync
4564a49301eSmrg   ctx->Extensions.ARB_sync = GL_TRUE;
4577117f1b4Smrg#endif
4587117f1b4Smrg   ctx->Extensions.APPLE_vertex_array_object = GL_TRUE;
459cdc920a0Smrg#if FEATURE_APPLE_object_purgeable
460cdc920a0Smrg   ctx->Extensions.APPLE_object_purgeable = GL_TRUE;
461cdc920a0Smrg#endif
4624a49301eSmrg   ctx->Extensions.ATI_envmap_bumpmap = GL_TRUE;
4637117f1b4Smrg#if FEATURE_ATI_fragment_shader
4647117f1b4Smrg   ctx->Extensions.ATI_fragment_shader = GL_TRUE;
4657117f1b4Smrg#endif
4663464ebd5Sriastradh   ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE;
4677117f1b4Smrg   ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
4687117f1b4Smrg   ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
4697117f1b4Smrg   ctx->Extensions.ATI_separate_stencil = GL_TRUE;
4707117f1b4Smrg   ctx->Extensions.EXT_blend_color = GL_TRUE;
4717117f1b4Smrg   ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
4727117f1b4Smrg   ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
4737117f1b4Smrg   ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
4747117f1b4Smrg   ctx->Extensions.EXT_blend_minmax = GL_TRUE;
4757117f1b4Smrg   ctx->Extensions.EXT_blend_subtract = GL_TRUE;
4767117f1b4Smrg   ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
477cdc920a0Smrg   ctx->Extensions.EXT_draw_buffers2 = GL_TRUE;
4787117f1b4Smrg   ctx->Extensions.EXT_fog_coord = GL_TRUE;
4797117f1b4Smrg#if FEATURE_EXT_framebuffer_object
4807117f1b4Smrg   ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
4817117f1b4Smrg#endif
4827117f1b4Smrg#if FEATURE_EXT_framebuffer_blit
4837117f1b4Smrg   ctx->Extensions.EXT_framebuffer_blit = GL_TRUE;
4844a49301eSmrg#endif
4854a49301eSmrg#if FEATURE_ARB_framebuffer_object
4864a49301eSmrg   ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE;
4877117f1b4Smrg#endif
4884a49301eSmrg   /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
4897117f1b4Smrg   ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
4907117f1b4Smrg   ctx->Extensions.EXT_paletted_texture = GL_TRUE;
4917117f1b4Smrg#if FEATURE_EXT_pixel_buffer_object
4927117f1b4Smrg   ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
4937117f1b4Smrg#endif
4947117f1b4Smrg   ctx->Extensions.EXT_point_parameters = GL_TRUE;
4954a49301eSmrg   ctx->Extensions.EXT_provoking_vertex = GL_TRUE;
4967117f1b4Smrg   ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
4977117f1b4Smrg   ctx->Extensions.EXT_secondary_color = GL_TRUE;
4987117f1b4Smrg   ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
4997117f1b4Smrg   ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
500c1f859d4Smrg   ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
501cdc920a0Smrg   ctx->Extensions.EXT_texture_array = GL_TRUE;
5023464ebd5Sriastradh   ctx->Extensions.EXT_texture_compression_latc = GL_TRUE;
5037117f1b4Smrg   ctx->Extensions.EXT_texture_env_add = GL_TRUE;
5047117f1b4Smrg   ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
5057117f1b4Smrg   ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
5063464ebd5Sriastradh   ctx->Extensions.EXT_texture_filter_anisotropic = GL_TRUE;
5077117f1b4Smrg   ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
5087117f1b4Smrg   ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
5093464ebd5Sriastradh   ctx->Extensions.EXT_texture_shared_exponent = GL_TRUE;
5107117f1b4Smrg#if FEATURE_EXT_texture_sRGB
5117117f1b4Smrg   ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
5123464ebd5Sriastradh   ctx->Extensions.EXT_texture_sRGB_decode = GL_TRUE;
5137117f1b4Smrg#endif
5144a49301eSmrg   ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
5153464ebd5Sriastradh#if FEATURE_EXT_transform_feedback
5163464ebd5Sriastradh   /*ctx->Extensions.EXT_transform_feedback = GL_TRUE;*/
5173464ebd5Sriastradh#endif
5184a49301eSmrg   ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
5194a49301eSmrg   /*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
5207117f1b4Smrg   ctx->Extensions.MESA_pack_invert = GL_TRUE;
5217117f1b4Smrg   ctx->Extensions.MESA_resize_buffers = GL_TRUE;
522c1f859d4Smrg   ctx->Extensions.MESA_texture_array = GL_TRUE;
5237117f1b4Smrg   ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
5247117f1b4Smrg   ctx->Extensions.NV_blend_square = GL_TRUE;
525cdc920a0Smrg   ctx->Extensions.NV_conditional_render = GL_TRUE;
5267117f1b4Smrg   /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
5277117f1b4Smrg   ctx->Extensions.NV_point_sprite = GL_TRUE;
5284a49301eSmrg   ctx->Extensions.NV_texture_env_combine4 = GL_TRUE;
5297117f1b4Smrg   ctx->Extensions.NV_texture_rectangle = GL_TRUE;
5307117f1b4Smrg   /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
5317117f1b4Smrg#if FEATURE_NV_vertex_program
5327117f1b4Smrg   ctx->Extensions.NV_vertex_program = GL_TRUE;
5337117f1b4Smrg   ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
5347117f1b4Smrg#endif
5357117f1b4Smrg#if FEATURE_NV_fragment_program
5367117f1b4Smrg   ctx->Extensions.NV_fragment_program = GL_TRUE;
5374a49301eSmrg#endif
5384a49301eSmrg#if FEATURE_NV_fragment_program && FEATURE_ARB_fragment_program
5394a49301eSmrg   ctx->Extensions.NV_fragment_program_option = GL_TRUE;
5407117f1b4Smrg#endif
5413464ebd5Sriastradh   /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/
5427117f1b4Smrg   ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
5437117f1b4Smrg#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
5447117f1b4Smrg   ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE;
5457117f1b4Smrg#endif
546c1f859d4Smrg#if FEATURE_texture_fxt1
547c1f859d4Smrg   _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
548c1f859d4Smrg#endif
549c1f859d4Smrg#if FEATURE_texture_s3tc
550c1f859d4Smrg   if (ctx->Mesa_DXTn) {
551c1f859d4Smrg      _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
552c1f859d4Smrg      _mesa_enable_extension(ctx, "GL_S3_s3tc");
553c1f859d4Smrg   }
554c1f859d4Smrg#endif
5557117f1b4Smrg}
5567117f1b4Smrg
5577117f1b4Smrg
5587117f1b4Smrg/**
5593464ebd5Sriastradh * Enable common EXT extensions in the ARB_imaging subset.
5607117f1b4Smrg */
5617117f1b4Smrgvoid
5623464ebd5Sriastradh_mesa_enable_imaging_extensions(struct gl_context *ctx)
5637117f1b4Smrg{
5647117f1b4Smrg   ctx->Extensions.EXT_blend_color = GL_TRUE;
565c1f859d4Smrg   ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
5667117f1b4Smrg   ctx->Extensions.EXT_blend_minmax = GL_TRUE;
5677117f1b4Smrg   ctx->Extensions.EXT_blend_subtract = GL_TRUE;
5687117f1b4Smrg}
5697117f1b4Smrg
5707117f1b4Smrg
5717117f1b4Smrg
5727117f1b4Smrg/**
5737117f1b4Smrg * Enable all OpenGL 1.3 features and extensions.
5747117f1b4Smrg * A convenience function to be called by drivers.
5757117f1b4Smrg */
5767117f1b4Smrgvoid
5773464ebd5Sriastradh_mesa_enable_1_3_extensions(struct gl_context *ctx)
5787117f1b4Smrg{
5794a49301eSmrg   /*ctx->Extensions.ARB_multisample = GL_TRUE;*/
5807117f1b4Smrg   ctx->Extensions.ARB_multitexture = GL_TRUE;
5817117f1b4Smrg   ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
5824a49301eSmrg   /*ctx->Extensions.ARB_texture_compression = GL_TRUE;*/
5837117f1b4Smrg   ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
5847117f1b4Smrg   ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
5857117f1b4Smrg   ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
5867117f1b4Smrg   ctx->Extensions.EXT_texture_env_add = GL_TRUE;
5877117f1b4Smrg   /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
5887117f1b4Smrg}
5897117f1b4Smrg
5907117f1b4Smrg
5917117f1b4Smrg
5927117f1b4Smrg/**
5937117f1b4Smrg * Enable all OpenGL 1.4 features and extensions.
5947117f1b4Smrg * A convenience function to be called by drivers.
5957117f1b4Smrg */
5967117f1b4Smrgvoid
5973464ebd5Sriastradh_mesa_enable_1_4_extensions(struct gl_context *ctx)
5987117f1b4Smrg{
5997117f1b4Smrg   ctx->Extensions.ARB_depth_texture = GL_TRUE;
6007117f1b4Smrg   ctx->Extensions.ARB_shadow = GL_TRUE;
6017117f1b4Smrg   ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
6027117f1b4Smrg   ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
6037117f1b4Smrg   ctx->Extensions.ARB_window_pos = GL_TRUE;
6047117f1b4Smrg   ctx->Extensions.EXT_blend_color = GL_TRUE;
6057117f1b4Smrg   ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
6067117f1b4Smrg   ctx->Extensions.EXT_blend_minmax = GL_TRUE;
6077117f1b4Smrg   ctx->Extensions.EXT_blend_subtract = GL_TRUE;
6087117f1b4Smrg   ctx->Extensions.EXT_fog_coord = GL_TRUE;
6094a49301eSmrg   /*ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;*/
6107117f1b4Smrg   ctx->Extensions.EXT_point_parameters = GL_TRUE;
6117117f1b4Smrg   ctx->Extensions.EXT_secondary_color = GL_TRUE;
6127117f1b4Smrg   ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
6137117f1b4Smrg   ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
6143464ebd5Sriastradh   /*ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;*/
6157117f1b4Smrg}
6167117f1b4Smrg
6177117f1b4Smrg
6187117f1b4Smrg/**
6197117f1b4Smrg * Enable all OpenGL 1.5 features and extensions.
6207117f1b4Smrg * A convenience function to be called by drivers.
6217117f1b4Smrg */
6227117f1b4Smrgvoid
6233464ebd5Sriastradh_mesa_enable_1_5_extensions(struct gl_context *ctx)
6247117f1b4Smrg{
6257117f1b4Smrg   ctx->Extensions.ARB_occlusion_query = GL_TRUE;
6264a49301eSmrg   /*ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;*/
6277117f1b4Smrg   ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
6287117f1b4Smrg}
6297117f1b4Smrg
6307117f1b4Smrg
6317117f1b4Smrg/**
6327117f1b4Smrg * Enable all OpenGL 2.0 features and extensions.
6337117f1b4Smrg * A convenience function to be called by drivers.
6347117f1b4Smrg */
6357117f1b4Smrgvoid
6363464ebd5Sriastradh_mesa_enable_2_0_extensions(struct gl_context *ctx)
6377117f1b4Smrg{
6384a49301eSmrg   /*ctx->Extensions.ARB_draw_buffers = GL_TRUE;*/
6397117f1b4Smrg#if FEATURE_ARB_fragment_shader
6407117f1b4Smrg   ctx->Extensions.ARB_fragment_shader = GL_TRUE;
6417117f1b4Smrg#endif
6427117f1b4Smrg   ctx->Extensions.ARB_point_sprite = GL_TRUE;
6434a49301eSmrg   ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
6447117f1b4Smrg   ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
6457117f1b4Smrg#if FEATURE_ARB_shader_objects
6467117f1b4Smrg   ctx->Extensions.ARB_shader_objects = GL_TRUE;
6477117f1b4Smrg#endif
6487117f1b4Smrg#if FEATURE_ARB_shading_language_100
6497117f1b4Smrg   ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
6507117f1b4Smrg#endif
651c1f859d4Smrg   ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
6527117f1b4Smrg#if FEATURE_ARB_vertex_shader
6537117f1b4Smrg   ctx->Extensions.ARB_vertex_shader = GL_TRUE;
6547117f1b4Smrg#endif
6557117f1b4Smrg}
6567117f1b4Smrg
6577117f1b4Smrg
6587117f1b4Smrg/**
6597117f1b4Smrg * Enable all OpenGL 2.1 features and extensions.
6607117f1b4Smrg * A convenience function to be called by drivers.
6617117f1b4Smrg */
6627117f1b4Smrgvoid
6633464ebd5Sriastradh_mesa_enable_2_1_extensions(struct gl_context *ctx)
6647117f1b4Smrg{
6657117f1b4Smrg#if FEATURE_EXT_pixel_buffer_object
6667117f1b4Smrg   ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
6677117f1b4Smrg#endif
6687117f1b4Smrg#if FEATURE_EXT_texture_sRGB
6697117f1b4Smrg   ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
6707117f1b4Smrg#endif
6717117f1b4Smrg}
6727117f1b4Smrg
6737117f1b4Smrg
6747117f1b4Smrg/**
6757117f1b4Smrg * Either enable or disable the named extension.
6764a49301eSmrg * \return GL_TRUE for success, GL_FALSE if invalid extension name
6777117f1b4Smrg */
6784a49301eSmrgstatic GLboolean
6793464ebd5Sriastradhset_extension( struct gl_context *ctx, const char *name, GLboolean state )
6807117f1b4Smrg{
6813464ebd5Sriastradh   size_t offset;
6827117f1b4Smrg
6837117f1b4Smrg   if (ctx->Extensions.String) {
6847117f1b4Smrg      /* The string was already queried - can't change it now! */
6857117f1b4Smrg      _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
6864a49301eSmrg      return GL_FALSE;
6877117f1b4Smrg   }
6887117f1b4Smrg
6893464ebd5Sriastradh   offset = name_to_offset(name);
6903464ebd5Sriastradh   if (offset == 0) {
6913464ebd5Sriastradh      _mesa_problem(ctx, "Trying to enable/disable unknown extension %s",
6923464ebd5Sriastradh	            name);
6933464ebd5Sriastradh      return GL_FALSE;
6943464ebd5Sriastradh   } else if (offset == o(dummy_true) && state == GL_FALSE) {
6953464ebd5Sriastradh      _mesa_problem(ctx, "Trying to disable a permanently enabled extension: "
6963464ebd5Sriastradh	                  "%s", name);
6973464ebd5Sriastradh      return GL_FALSE;
6983464ebd5Sriastradh   } else {
6993464ebd5Sriastradh      GLboolean *base = (GLboolean *) &ctx->Extensions;
7003464ebd5Sriastradh      base[offset] = state;
7013464ebd5Sriastradh      return GL_TRUE;
7027117f1b4Smrg   }
7037117f1b4Smrg}
7047117f1b4Smrg
7057117f1b4Smrg
7067117f1b4Smrg/**
7077117f1b4Smrg * Enable the named extension.
7087117f1b4Smrg * Typically called by drivers.
7097117f1b4Smrg */
7107117f1b4Smrgvoid
7113464ebd5Sriastradh_mesa_enable_extension( struct gl_context *ctx, const char *name )
7127117f1b4Smrg{
7134a49301eSmrg   if (!set_extension(ctx, name, GL_TRUE))
7144a49301eSmrg      _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
7157117f1b4Smrg}
7167117f1b4Smrg
7177117f1b4Smrg
7187117f1b4Smrg/**
7197117f1b4Smrg * Disable the named extension.
7207117f1b4Smrg * XXX is this really needed???
7217117f1b4Smrg */
7227117f1b4Smrgvoid
7233464ebd5Sriastradh_mesa_disable_extension( struct gl_context *ctx, const char *name )
7247117f1b4Smrg{
7254a49301eSmrg   if (!set_extension(ctx, name, GL_FALSE))
7264a49301eSmrg      _mesa_problem(ctx, "Trying to disable unknown extension: %s", name);
7277117f1b4Smrg}
7287117f1b4Smrg
7297117f1b4Smrg
730cdc920a0Smrg/**
7313464ebd5Sriastradh * Test if the named extension is enabled in this context.
732cdc920a0Smrg */
7333464ebd5SriastradhGLboolean
7343464ebd5Sriastradh_mesa_extension_is_enabled( struct gl_context *ctx, const char *name )
735cdc920a0Smrg{
7363464ebd5Sriastradh   size_t offset;
7373464ebd5Sriastradh   GLboolean *base;
7383464ebd5Sriastradh
7393464ebd5Sriastradh   if (name == 0)
740cdc920a0Smrg      return GL_FALSE;
7413464ebd5Sriastradh
7423464ebd5Sriastradh   offset = name_to_offset(name);
7433464ebd5Sriastradh   if (offset == 0)
7443464ebd5Sriastradh      return GL_FALSE;
7453464ebd5Sriastradh   base = (GLboolean *) &ctx->Extensions;
7463464ebd5Sriastradh   return base[offset];
747cdc920a0Smrg}
748cdc920a0Smrg
749cdc920a0Smrg
7507117f1b4Smrg/**
7513464ebd5Sriastradh * \brief Apply the \c MESA_EXTENSION_OVERRIDE environment variable.
7523464ebd5Sriastradh *
7533464ebd5Sriastradh * \c MESA_EXTENSION_OVERRIDE is a space-separated list of extensions to
7543464ebd5Sriastradh * enable or disable. The list is processed thus:
7553464ebd5Sriastradh *    - Enable recognized extension names that are prefixed with '+'.
7563464ebd5Sriastradh *    - Disable recognized extension names that are prefixed with '-'.
7573464ebd5Sriastradh *    - Enable recognized extension names that are not prefixed.
7583464ebd5Sriastradh *    - Collect unrecognized extension names in a new string.
7593464ebd5Sriastradh *
7603464ebd5Sriastradh * \return Space-separated list of unrecognized extension names (which must
7613464ebd5Sriastradh *    be freed). Does not return \c NULL.
7627117f1b4Smrg */
7633464ebd5Sriastradhstatic char *
7643464ebd5Sriastradhget_extension_override( struct gl_context *ctx )
7657117f1b4Smrg{
7663464ebd5Sriastradh   const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE");
7673464ebd5Sriastradh   char *env;
7683464ebd5Sriastradh   char *ext;
7693464ebd5Sriastradh   char *extra_exts;
7703464ebd5Sriastradh   int len;
7713464ebd5Sriastradh
7723464ebd5Sriastradh   if (env_const == NULL) {
7733464ebd5Sriastradh      /* Return the empty string rather than NULL. This simplifies the logic
7743464ebd5Sriastradh       * of client functions. */
7753464ebd5Sriastradh      return calloc(1, sizeof(char));
7763464ebd5Sriastradh   }
7777117f1b4Smrg
7783464ebd5Sriastradh   /* extra_exts: List of unrecognized extensions. */
7793464ebd5Sriastradh   extra_exts = calloc(strlen(env_const), sizeof(char));
7803464ebd5Sriastradh
7813464ebd5Sriastradh   /* Copy env_const because strtok() is destructive. */
7823464ebd5Sriastradh   env = strdup(env_const);
7833464ebd5Sriastradh   for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) {
7843464ebd5Sriastradh      int enable;
7853464ebd5Sriastradh      int recognized;
7863464ebd5Sriastradh      switch (ext[0]) {
7873464ebd5Sriastradh      case '+':
7883464ebd5Sriastradh         enable = 1;
7893464ebd5Sriastradh         ++ext;
7903464ebd5Sriastradh         break;
7913464ebd5Sriastradh      case '-':
7923464ebd5Sriastradh         enable = 0;
7933464ebd5Sriastradh         ++ext;
7943464ebd5Sriastradh         break;
7953464ebd5Sriastradh      default:
7963464ebd5Sriastradh         enable = 1;
7973464ebd5Sriastradh         break;
7983464ebd5Sriastradh      }
7993464ebd5Sriastradh      recognized = set_extension(ctx, ext, enable);
8003464ebd5Sriastradh      if (!recognized) {
8013464ebd5Sriastradh         strcat(extra_exts, ext);
8023464ebd5Sriastradh         strcat(extra_exts, " ");
8037117f1b4Smrg      }
8047117f1b4Smrg   }
8057117f1b4Smrg
8063464ebd5Sriastradh   /* Remove trailing space. */
8073464ebd5Sriastradh   len = strlen(extra_exts);
8083464ebd5Sriastradh   if (extra_exts[len - 1] == ' ')
8093464ebd5Sriastradh      extra_exts[len - 1] = '\0';
8107117f1b4Smrg
8113464ebd5Sriastradh   return extra_exts;
8124a49301eSmrg}
8134a49301eSmrg
8144a49301eSmrg
8154a49301eSmrg/**
8163464ebd5Sriastradh * \brief Initialize extension tables and enable default extensions.
8173464ebd5Sriastradh *
8183464ebd5Sriastradh * This should be called during context initialization.
8193464ebd5Sriastradh * Note: Sets gl_extensions.dummy_true to true.
8204a49301eSmrg */
8213464ebd5Sriastradhvoid
8223464ebd5Sriastradh_mesa_init_extensions( struct gl_context *ctx )
8234a49301eSmrg{
8243464ebd5Sriastradh   GLboolean *base = (GLboolean *) &ctx->Extensions;
8253464ebd5Sriastradh   GLboolean *sentinel = base + o(extension_sentinel);
8263464ebd5Sriastradh   GLboolean *i;
8273464ebd5Sriastradh   const size_t *j;
8283464ebd5Sriastradh
8293464ebd5Sriastradh   /* First, turn all extensions off. */
8303464ebd5Sriastradh   for (i = base; i != sentinel; ++i)
8313464ebd5Sriastradh      *i = GL_FALSE;
8323464ebd5Sriastradh
8333464ebd5Sriastradh   /* Then, selectively turn default extensions on. */
8343464ebd5Sriastradh   ctx->Extensions.dummy_true = GL_TRUE;
8353464ebd5Sriastradh   for (j = default_extensions; *j != 0; ++j)
8363464ebd5Sriastradh      base[*j] = GL_TRUE;
8373464ebd5Sriastradh}
8384a49301eSmrg
8394a49301eSmrg
8403464ebd5Sriastradhtypedef unsigned short extension_index;
8414a49301eSmrg
8424a49301eSmrg
8437117f1b4Smrg/**
8443464ebd5Sriastradh * Compare two entries of the extensions table.  Sorts first by year,
8453464ebd5Sriastradh * then by name.
8463464ebd5Sriastradh *
8473464ebd5Sriastradh * Arguments are indices into extension_table.
8487117f1b4Smrg */
8493464ebd5Sriastradhstatic int
8503464ebd5Sriastradhextension_compare(const void *p1, const void *p2)
8517117f1b4Smrg{
8523464ebd5Sriastradh   extension_index i1 = * (const extension_index *) p1;
8533464ebd5Sriastradh   extension_index i2 = * (const extension_index *) p2;
8543464ebd5Sriastradh   const struct extension *e1 = &extension_table[i1];
8553464ebd5Sriastradh   const struct extension *e2 = &extension_table[i2];
8563464ebd5Sriastradh   int res;
8577117f1b4Smrg
8583464ebd5Sriastradh   res = (int)e1->year - (int)e2->year;
8593464ebd5Sriastradh
8603464ebd5Sriastradh   if (res == 0) {
8613464ebd5Sriastradh      res = strcmp(e1->name, e2->name);
8627117f1b4Smrg   }
8633464ebd5Sriastradh
8643464ebd5Sriastradh   return res;
8657117f1b4Smrg}
8667117f1b4Smrg
8677117f1b4Smrg
8687117f1b4Smrg/**
8697117f1b4Smrg * Construct the GL_EXTENSIONS string.  Called the first time that
8707117f1b4Smrg * glGetString(GL_EXTENSIONS) is called.
8717117f1b4Smrg */
8723464ebd5SriastradhGLubyte*
8733464ebd5Sriastradh_mesa_make_extension_string(struct gl_context *ctx)
8747117f1b4Smrg{
8753464ebd5Sriastradh   /* The extension string. */
8763464ebd5Sriastradh   char *exts = 0;
8773464ebd5Sriastradh   /* Length of extension string. */
8783464ebd5Sriastradh   size_t length = 0;
8793464ebd5Sriastradh   /* Number of extensions */
8803464ebd5Sriastradh   unsigned count;
8813464ebd5Sriastradh   /* Indices of the extensions sorted by year */
8823464ebd5Sriastradh   extension_index *extension_indices;
8833464ebd5Sriastradh   /* String of extra extensions. */
8843464ebd5Sriastradh   char *extra_extensions = get_extension_override(ctx);
8853464ebd5Sriastradh   GLboolean *base = (GLboolean *) &ctx->Extensions;
8863464ebd5Sriastradh   const struct extension *i;
8873464ebd5Sriastradh   unsigned j;
8883464ebd5Sriastradh   unsigned maxYear = ~0;
8893464ebd5Sriastradh
8903464ebd5Sriastradh   /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */
8913464ebd5Sriastradh   {
8923464ebd5Sriastradh      const char *env = getenv("MESA_EXTENSION_MAX_YEAR");
8933464ebd5Sriastradh      if (env) {
8943464ebd5Sriastradh         maxYear = atoi(env);
8953464ebd5Sriastradh         _mesa_debug(ctx, "Note: limiting GL extensions to %u or earlier\n",
8963464ebd5Sriastradh                     maxYear);
8977117f1b4Smrg      }
8987117f1b4Smrg   }
8994a49301eSmrg
9003464ebd5Sriastradh   /* Compute length of the extension string. */
9013464ebd5Sriastradh   count = 0;
9023464ebd5Sriastradh   for (i = extension_table; i->name != 0; ++i) {
9033464ebd5Sriastradh      if (base[i->offset] &&
9043464ebd5Sriastradh          i->year <= maxYear &&
9053464ebd5Sriastradh          (i->api_set & (1 << ctx->API))) {
9063464ebd5Sriastradh	 length += strlen(i->name) + 1; /* +1 for space */
9073464ebd5Sriastradh	 ++count;
9083464ebd5Sriastradh      }
9093464ebd5Sriastradh   }
9103464ebd5Sriastradh   if (extra_extensions != NULL)
9113464ebd5Sriastradh      length += 1 + strlen(extra_extensions); /* +1 for space */
9124a49301eSmrg
9133464ebd5Sriastradh   exts = (char *) calloc(length + 1, sizeof(char));
9143464ebd5Sriastradh   if (exts == NULL) {
9153464ebd5Sriastradh      free(extra_extensions);
9164a49301eSmrg      return NULL;
9177117f1b4Smrg   }
9187117f1b4Smrg
9193464ebd5Sriastradh   extension_indices = malloc(count * sizeof(extension_index));
9203464ebd5Sriastradh   if (extension_indices == NULL) {
9213464ebd5Sriastradh      free(exts);
9223464ebd5Sriastradh      free(extra_extensions);
9233464ebd5Sriastradh      return NULL;
9243464ebd5Sriastradh   }
9257117f1b4Smrg
9263464ebd5Sriastradh   /* Sort extensions in chronological order because certain old applications (e.g.,
9273464ebd5Sriastradh    * Quake3 demo) store the extension list in a static size buffer so chronologically
9283464ebd5Sriastradh    * order ensure that the extensions that such applications expect will fit into
9293464ebd5Sriastradh    * that buffer.
9303464ebd5Sriastradh    */
9313464ebd5Sriastradh   j = 0;
9323464ebd5Sriastradh   for (i = extension_table; i->name != 0; ++i) {
9333464ebd5Sriastradh      if (base[i->offset] &&
9343464ebd5Sriastradh          i->year <= maxYear &&
9353464ebd5Sriastradh          (i->api_set & (1 << ctx->API))) {
9363464ebd5Sriastradh         extension_indices[j++] = i - extension_table;
9373464ebd5Sriastradh      }
9383464ebd5Sriastradh   }
9393464ebd5Sriastradh   assert(j == count);
9403464ebd5Sriastradh   qsort(extension_indices, count, sizeof *extension_indices, extension_compare);
9413464ebd5Sriastradh
9423464ebd5Sriastradh   /* Build the extension string.*/
9433464ebd5Sriastradh   for (j = 0; j < count; ++j) {
9443464ebd5Sriastradh      i = &extension_table[extension_indices[j]];
9453464ebd5Sriastradh      assert(base[i->offset] && (i->api_set & (1 << ctx->API)));
9463464ebd5Sriastradh      strcat(exts, i->name);
9473464ebd5Sriastradh      strcat(exts, " ");
9483464ebd5Sriastradh   }
9493464ebd5Sriastradh   free(extension_indices);
9503464ebd5Sriastradh   if (extra_extensions != 0) {
9513464ebd5Sriastradh      strcat(exts, extra_extensions);
9523464ebd5Sriastradh      free(extra_extensions);
9534a49301eSmrg   }
9544a49301eSmrg
9553464ebd5Sriastradh   return (GLubyte *) exts;
9567117f1b4Smrg}
957cdc920a0Smrg
958cdc920a0Smrg/**
959cdc920a0Smrg * Return number of enabled extensions.
960cdc920a0Smrg */
961cdc920a0SmrgGLuint
9623464ebd5Sriastradh_mesa_get_extension_count(struct gl_context *ctx)
963cdc920a0Smrg{
9643464ebd5Sriastradh   GLboolean *base;
9653464ebd5Sriastradh   const struct extension *i;
966cdc920a0Smrg
967cdc920a0Smrg   /* only count once */
9683464ebd5Sriastradh   if (ctx->Extensions.Count != 0)
9693464ebd5Sriastradh      return ctx->Extensions.Count;
9703464ebd5Sriastradh
9713464ebd5Sriastradh   base = (GLboolean *) &ctx->Extensions;
9723464ebd5Sriastradh   for (i = extension_table; i->name != 0; ++i) {
9733464ebd5Sriastradh      if (base[i->offset]) {
9743464ebd5Sriastradh	 ctx->Extensions.Count++;
975cdc920a0Smrg      }
976cdc920a0Smrg   }
977cdc920a0Smrg   return ctx->Extensions.Count;
978cdc920a0Smrg}
979cdc920a0Smrg
980cdc920a0Smrg/**
981cdc920a0Smrg * Return name of i-th enabled extension
982cdc920a0Smrg */
983cdc920a0Smrgconst GLubyte *
9843464ebd5Sriastradh_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index)
985cdc920a0Smrg{
9863464ebd5Sriastradh   const GLboolean *base;
9873464ebd5Sriastradh   size_t n;
9883464ebd5Sriastradh   const struct extension *i;
9893464ebd5Sriastradh
9903464ebd5Sriastradh   if (index < 0)
9913464ebd5Sriastradh      return NULL;
992cdc920a0Smrg
9933464ebd5Sriastradh   base = (GLboolean*) &ctx->Extensions;
9943464ebd5Sriastradh   n = 0;
9953464ebd5Sriastradh   for (i = extension_table; i->name != 0; ++i) {
9963464ebd5Sriastradh      if (n == index && base[i->offset]) {
9973464ebd5Sriastradh	 return (GLubyte*) i->name;
9983464ebd5Sriastradh      } else if (base[i->offset]) {
9993464ebd5Sriastradh	 ++n;
1000cdc920a0Smrg      }
1001cdc920a0Smrg   }
1002cdc920a0Smrg
1003cdc920a0Smrg   return NULL;
1004cdc920a0Smrg}
1005