glx/dri: only report DRI2 extensions when DRI2 is enabled.
[mesa.git] / src / glx / x11 / glxextensions.c
index 166dd18c041c9c3df34043f10a1ec8c5dbdc792d..e84371847225d04fc328acc352ec373e5557ee7f 100644 (file)
@@ -29,8 +29,8 @@
  */
 
 #include "glxclient.h"
-#include <extutil.h>
-#include <Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/Xext.h>
 #include <string.h>
 #include "glapi.h"
 #include "glxextensions.h"
@@ -79,45 +79,41 @@ static const struct extension_info known_glx_extensions[] = {
    { GLX(EXT_visual_rating),           VER(0,0), Y, Y, N, N },
    { GLX(MESA_agp_offset),             VER(0,0), N, N, N, Y }, /* Deprecated */
    { GLX(MESA_allocate_memory),        VER(0,0), Y, N, N, Y },
-   { GLX(MESA_copy_sub_buffer),        VER(0,0), N, N, N, N }, /* Deprecated? */
+   { GLX(MESA_copy_sub_buffer),        VER(0,0), Y, N, N, N },
    { GLX(MESA_pixmap_colormap),        VER(0,0), N, N, N, N }, /* Deprecated */
    { GLX(MESA_release_buffers),        VER(0,0), N, N, N, N }, /* Deprecated */
-   { GLX(MESA_set_3dfx_mode),          VER(0,0), N, N, N, N }, /* Deprecated */
    { GLX(MESA_swap_control),           VER(0,0), Y, N, N, Y },
    { GLX(MESA_swap_frame_usage),       VER(0,0), Y, N, N, Y },
    { GLX(NV_float_buffer),             VER(0,0), N, N, N, N },
    { GLX(NV_render_depth_texture),     VER(0,0), N, N, N, N },
    { GLX(NV_render_texture_rectangle), VER(0,0), N, N, N, N },
    { GLX(NV_vertex_array_range),       VER(0,0), N, N, N, Y }, /* Deprecated */
-   { GLX(OML_swap_method),             VER(0,0), Y, N, N, N },
+   { GLX(OML_swap_method),             VER(0,0), Y, Y, N, N },
    { GLX(OML_sync_control),            VER(0,0), Y, N, N, Y },
-   { GLX(SGI_cushion),                 VER(0,0), N, N, N, N },
    { GLX(SGI_make_current_read),       VER(1,3), Y, N, N, N },
    { GLX(SGI_swap_control),            VER(0,0), Y, N, N, N },
    { GLX(SGI_video_sync),              VER(0,0), Y, N, N, Y },
    { GLX(SGIS_blended_overlay),        VER(0,0), N, N, N, N },
    { GLX(SGIS_color_range),            VER(0,0), N, N, N, N },
    { GLX(SGIS_multisample),            VER(0,0), Y, Y, N, N },
-   { GLX(SGIX_dm_buffer),              VER(0,0), N, N, N, N },
-   { GLX(SGIX_fbconfig),               VER(1,3), Y, N, N, N },
+   { GLX(SGIX_fbconfig),               VER(1,3), Y, Y, N, N },
    { GLX(SGIX_pbuffer),                VER(1,3), Y, N, N, N },
    { GLX(SGIX_swap_barrier),           VER(0,0), N, N, N, N },
    { GLX(SGIX_swap_group),             VER(0,0), N, N, N, N },
-   { GLX(SGIX_video_resize),           VER(0,0), N, N, N, N },
-   { GLX(SGIX_video_source),           VER(0,0), N, N, N, N },
    { GLX(SGIX_visual_select_group),    VER(0,0), Y, Y, N, N },
-   { GLX(SUN_get_transparent_index),   VER(0,0), N, N, N, N },
+   { GLX(EXT_texture_from_pixmap),     VER(0,0), Y, N, N, N },
    { NULL }
 };
 
 static const struct extension_info known_gl_extensions[] = {
    { GL(ARB_depth_texture),              VER(1,4), Y, N, N, N },
+   { GL(ARB_draw_buffers),               VER(0,0), Y, N, N, N },
    { GL(ARB_fragment_program),           VER(0,0), Y, N, N, N },
    { GL(ARB_fragment_program_shadow),    VER(0,0), Y, N, N, N },
    { GL(ARB_imaging),                    VER(0,0), Y, N, N, N },
    { GL(ARB_multisample),                VER(1,3), Y, N, N, N },
    { GL(ARB_multitexture),               VER(1,3), Y, N, N, N },
-   { GL(ARB_occlusion_query),            VER(1,5), N, N, N, N },
+   { GL(ARB_occlusion_query),            VER(1,5), Y, N, N, N },
    { GL(ARB_point_parameters),           VER(1,4), Y, N, N, N },
    { GL(ARB_point_sprite),               VER(0,0), Y, N, N, N },
    { GL(ARB_shadow),                     VER(1,4), Y, N, N, N },
@@ -139,7 +135,7 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(EXT_abgr),                       VER(0,0), Y, N, N, N },
    { GL(EXT_bgra),                       VER(1,2), Y, N, N, N },
    { GL(EXT_blend_color),                VER(1,4), Y, N, N, N },
-   { GL(EXT_blend_equation_separate),    VER(0,0), N, N, N, N },
+   { GL(EXT_blend_equation_separate),    VER(0,0), Y, N, N, N },
    { GL(EXT_blend_func_separate),        VER(1,4), Y, N, N, N },
    { GL(EXT_blend_logic_op),             VER(1,4), Y, N, N, N },
    { GL(EXT_blend_minmax),               VER(1,4), Y, N, N, N },
@@ -152,6 +148,7 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(EXT_depth_bounds_test),          VER(0,0), N, N, N, N },
    { GL(EXT_draw_range_elements),        VER(1,2), Y, N, Y, N },
    { GL(EXT_fog_coord),                  VER(1,4), Y, N, N, N },
+   { GL(EXT_framebuffer_object),         VER(0,0), Y, N, N, N },
    { GL(EXT_multi_draw_arrays),          VER(1,4), Y, N, Y, N },
    { GL(EXT_packed_pixels),              VER(1,2), Y, N, N, N },
    { GL(EXT_paletted_texture),           VER(0,0), Y, N, N, N },
@@ -184,6 +181,7 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(3DFX_texture_compression_FXT1),  VER(0,0), Y, N, N, N },
    { GL(APPLE_packed_pixels),            VER(1,2), Y, N, N, N },
    { GL(APPLE_ycbcr_422),                VER(0,0), Y, N, N, N },
+   { GL(ATI_draw_buffers),               VER(0,0), Y, N, N, N },
    { GL(ATI_text_fragment_shader),       VER(0,0), Y, N, N, N },
    { GL(ATI_texture_env_combine3),       VER(0,0), Y, N, N, N },
    { GL(ATI_texture_float),              VER(0,0), Y, N, N, N },
@@ -222,6 +220,7 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(OES_read_format),                VER(0,0), Y, N, N, N },
    { GL(OES_compressed_paletted_texture),VER(0,0), Y, N, N, N },
    { GL(SGI_color_matrix),               VER(0,0), Y, N, N, N },
+   { GL(SGI_color_table),                VER(0,0), Y, N, N, N },
    { GL(SGI_texture_color_table),        VER(0,0), Y, N, N, N },
    { GL(SGIS_generate_mipmap),           VER(1,4), Y, N, N, N },
    { GL(SGIS_multisample),               VER(0,0), Y, N, N, N },
@@ -264,8 +263,8 @@ static unsigned char direct_glx_support[8];
 /**
  * Highest core GL version that can be supported for indirect rendering.
  */
-static unsigned gl_major = 0;
-static unsigned gl_minor = 0;
+static const unsigned gl_major = 1;
+static const unsigned gl_minor = 4;
 
 /* client extensions string */
 static const char * __glXGLXClientExtensions = NULL;
@@ -315,6 +314,11 @@ set_glx_extension( const struct extension_info * ext,
  * 
  * \param server_string   GLX extension string from the server.
  * \param server_support  Bit-field of supported extensions.
+ * 
+ * \note
+ * This function is used to process both GLX and GL extension strings.  The
+ * bit-fields used to track each of these have different sizes.  Therefore,
+ * the data pointed by \c server_support must be preinitialized to zero.
  */
 static void
 __glXProcessServerString( const struct extension_info * ext,
@@ -324,8 +328,6 @@ __glXProcessServerString( const struct extension_info * ext,
    unsigned  base;
    unsigned  len;
 
-   (void) memset( server_support, 0, sizeof( server_support ) );
-   
    for ( base = 0 ; server_string[ base ] != NUL ; /* empty */ ) {
       /* Determine the length of the next extension name.
        */
@@ -354,28 +356,15 @@ __glXProcessServerString( const struct extension_info * ext,
    }
 }
 
-
-/**
- * Enable a named GLX extension on a given screen.
- * Drivers should not call this function directly.  They should instead use
- * \c glXGetProcAddress to obtain a pointer to the function.
- *
- * \param psc   Pointer to GLX per-screen record.
- * \param name  Name of the extension to enable.
- *
- * \sa glXGetProcAddress
- *
- * \since Internal API version 20030813.
- */
 void
-__glXScrEnableExtension( __GLXscreenConfigs *psc, const char * name )
+__glXEnableDirectExtension(__GLXscreenConfigs *psc, const char *name)
 {
-   __glXExtensionsCtr();
-   __glXExtensionsCtrScreen(psc);
-   set_glx_extension( known_glx_extensions, name, strlen( name ), GL_TRUE,
-                     psc->direct_support );
-}
+    __glXExtensionsCtr();
+    __glXExtensionsCtrScreen(psc);
 
+    set_glx_extension(known_glx_extensions,
+                     name, strlen(name), GL_TRUE, psc->direct_support);
+}
 
 /**
  * Initialize global extension support tables.
@@ -384,11 +373,8 @@ __glXScrEnableExtension( __GLXscreenConfigs *psc, const char * name )
 static void
 __glXExtensionsCtr( void )
 {
-   static const char major_table[32] = { 1, 1, 1, 1, 1, 1, 2, };
-   static const char minor_table[32] = { 0, 1, 2, 3, 4, 5, 0, };
    unsigned   i;
    static GLboolean ext_list_first_time = GL_TRUE;
-   unsigned   full_support = ~0;
 
 
    if ( ext_list_first_time ) {
@@ -428,31 +414,12 @@ __glXExtensionsCtr( void )
         if ( known_gl_extensions[i].client_support ) {
            SET_BIT( client_gl_support, bit );
         }
-        else if ( known_gl_extensions[i].version_major != 0 ) {
-           /* If an extension that is required for some core GL version is
-            * not supported, clear the bit for that core GL version as well.
-            */
-
-           unsigned ver_bit = (6 * (known_gl_extensions[i].version_major - 1))
-             + (known_gl_extensions[i].version_minor);
-
-           full_support &= ~(1U << ver_bit);
-        }
 
         if ( known_gl_extensions[i].client_only ) {
            SET_BIT( client_gl_only, bit );
         }
       }
       
-      /* Determine the lowest unsupported core GL version.  The version before
-       * that is, therefore, the highest supported core GL version.
-       */
-      for ( i = 0 ; (full_support & (1 << i)) != 0 ; i++ )
-        /* empty */ ;
-
-      i--;
-      gl_major = major_table[i];
-      gl_minor = minor_table[i];
 #if 0
       fprintf( stderr, "[%s:%u] Maximum client library version: %u.%u\n",
               __func__, __LINE__, gl_major, gl_minor );
@@ -598,6 +565,8 @@ __glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
 
    __glXExtensionsCtr();
    __glXExtensionsCtrScreen( psc );
+
+   (void) memset( server_support, 0, sizeof( server_support ) );
    __glXProcessServerString( known_glx_extensions,
                             psc->serverGLXexts, server_support );