bring in changes from 6.4 branch
[mesa.git] / src / glx / x11 / glxextensions.c
index 8e7afa6b4b56124101eca822dc0b51c72a60f0b3..d2597981cf304e3855ef69bfab48a99a1fa35fd9 100644 (file)
  *
  * \author Ian Romanick <idr@us.ibm.com>
  */
-/* $XFree86: xc/lib/GL/glx/glxextensions.c,v 1.1 2003/09/28 20:15:03 alanh Exp $ */
 
 #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"
@@ -90,7 +89,7 @@ static const struct extension_info known_glx_extensions[] = {
    { 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 },
@@ -100,7 +99,7 @@ static const struct extension_info known_glx_extensions[] = {
    { 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 },
@@ -113,17 +112,19 @@ static const struct extension_info known_glx_extensions[] = {
 
 static const struct extension_info known_gl_extensions[] = {
    { GL(ARB_depth_texture),              VER(1,4), Y, N, N, N },
-   { GL(ARB_fragment_program),           VER(0,0), N, 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 },
    { GL(ARB_shadow_ambient),             VER(0,0), Y, N, N, N },
    { GL(ARB_texture_border_clamp),       VER(1,3), Y, N, N, N },
-   { GL(ARB_texture_compression),        VER(1,3), N, N, N, N },
+   { GL(ARB_texture_compression),        VER(1,3), Y, N, N, N },
    { GL(ARB_texture_cube_map),           VER(1,3), Y, N, N, N },
    { GL(ARB_texture_env_add),            VER(1,3), Y, N, N, N },
    { GL(ARB_texture_env_combine),        VER(1,3), Y, N, N, N },
@@ -131,8 +132,10 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(ARB_texture_env_dot3),           VER(1,3), Y, N, N, N },
    { GL(ARB_texture_mirrored_repeat),    VER(1,4), Y, N, N, N },
    { GL(ARB_texture_non_power_of_two),   VER(1,5), Y, N, N, N },
+   { GL(ARB_texture_rectangle),          VER(0,0), Y, N, N, N },
    { GL(ARB_transpose_matrix),           VER(1,3), Y, N, Y, N },
    { GL(ARB_vertex_buffer_object),       VER(1,5), N, N, N, N },
+   { GL(ARB_vertex_program),             VER(0,0), Y, N, N, N },
    { GL(ARB_window_pos),                 VER(1,4), Y, N, N, N },
    { GL(EXT_abgr),                       VER(0,0), Y, N, N, N },
    { GL(EXT_bgra),                       VER(1,2), Y, N, N, N },
@@ -166,7 +169,8 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(EXT_subtexture),                 VER(1,1), Y, N, N, N },
    { GL(EXT_texture),                    VER(1,1), Y, N, N, N },
    { GL(EXT_texture3D),                  VER(1,2), Y, N, N, N },
-   { GL(EXT_texture_compression_s3tc),   VER(0,0), N, N, N, N },
+   { GL(EXT_texture_compression_dxt1),   VER(0,0), Y, N, N, N },
+   { GL(EXT_texture_compression_s3tc),   VER(0,0), Y, N, N, N },
    { GL(EXT_texture_edge_clamp),         VER(1,2), Y, N, N, N },
    { GL(EXT_texture_env_add),            VER(1,3), Y, N, N, N },
    { GL(EXT_texture_env_combine),        VER(1,3), Y, N, N, N },
@@ -178,21 +182,17 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(EXT_texture_object),             VER(1,1), Y, N, N, N },
    { GL(EXT_texture_rectangle),          VER(0,0), Y, N, N, N },
    { GL(EXT_vertex_array),               VER(0,0), Y, N, N, N },
-   { GL(3DFX_texture_compression_FXT1),  VER(0,0), N, N, N, N },
+   { 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 },
    { GL(ATI_texture_mirror_once),        VER(0,0), Y, N, N, N },
    { GL(ATIX_texture_env_combine3),      VER(0,0), Y, N, N, N },
    { GL(HP_convolution_border_modes),    VER(0,0), Y, N, N, N },
-
-    /* This is currently removed because there seem to be some problems with
-     * it and the software-only indirect rendering path.  At this point, I'm
-     * not sure which side (client or server) has the problem. - idr
-     */
-   { GL(HP_occlusion_test),              VER(0,0), N, N, N, N },
-
+   { GL(HP_occlusion_test),              VER(0,0), Y, N, N, N },
    { GL(IBM_cull_vertex),                VER(0,0), Y, N, N, N },
    { GL(IBM_pixel_filter_hint),          VER(0,0), Y, N, N, N },
    { GL(IBM_rasterpos_clip),             VER(0,0), Y, N, N, N },
@@ -206,13 +206,25 @@ static const struct extension_info known_gl_extensions[] = {
    { GL(NV_copy_depth_to_color),         VER(0,0), Y, N, N, N },
    { GL(NV_depth_clamp),                 VER(0,0), Y, N, N, N },
    { GL(NV_fog_distance),                VER(0,0), Y, N, N, N },
+   { GL(NV_fragment_program),            VER(0,0), Y, N, N, N },
+   { GL(NV_fragment_program_option),     VER(0,0), Y, N, N, N },
+   { GL(NV_fragment_program2),           VER(0,0), Y, N, N, N },
    { GL(NV_light_max_exponent),          VER(0,0), Y, N, N, N },
    { GL(NV_multisample_filter_hint),     VER(0,0), Y, N, N, N },
    { GL(NV_point_sprite),                VER(0,0), Y, N, N, N },
    { GL(NV_texgen_reflection),           VER(0,0), Y, N, N, N },
-   { GL(NV_texture_compression_vtc),     VER(0,0), N, N, N, N },
+   { GL(NV_texture_compression_vtc),     VER(0,0), Y, N, N, N },
    { GL(NV_texture_env_combine4),        VER(0,0), Y, N, N, N },
    { GL(NV_texture_rectangle),           VER(0,0), Y, N, N, N },
+   { GL(NV_vertex_program),              VER(0,0), Y, N, N, N },
+   { GL(NV_vertex_program1_1),           VER(0,0), Y, N, N, N },
+   { GL(NV_vertex_program2),             VER(0,0), Y, N, N, N },
+   { GL(NV_vertex_program2_option),      VER(0,0), Y, N, N, N },
+   { GL(NV_vertex_program3),             VER(0,0), Y, N, N, N },
+   { 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_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 },
    { GL(SGIS_texture_border_clamp),      VER(1,3), Y, N, N, N },
@@ -238,8 +250,6 @@ static const struct extension_info known_gl_extensions[] = {
 };
 
 
-#define __GL_EXT_BYTES   ((__NUM_GL_EXTS + 7) / 8)
-
 /* global bit-fields of available extensions and their characteristics */
 static unsigned char client_glx_support[8];
 static unsigned char client_glx_only[8];
@@ -256,8 +266,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;
@@ -376,11 +386,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 ) {
@@ -420,31 +427,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 );
@@ -494,6 +482,24 @@ __glXExtensionBitIsEnabled( __GLXscreenConfigs *psc, unsigned bit )
 }
 
 
+/**
+ * Check if a certain extension is enabled in a given context.
+ *
+ */
+GLboolean
+__glExtensionBitIsEnabled( const __GLXcontext * gc, unsigned bit )
+{
+   GLboolean enabled = GL_FALSE;
+
+   if ( gc != NULL ) {
+      enabled = EXT_ENABLED( bit, gc->gl_extension_bits );
+   }
+
+   return enabled;
+}
+
+
+
 /**
  * Convert a bit-field to a string of supported extensions.
  */
@@ -681,6 +687,7 @@ __glXCalculateUsableGLExtensions( __GLXcontext * gc,
 
    gc->extensions = (unsigned char *) 
      __glXGetStringFromTable( known_gl_extensions, usable );
+   (void) memcpy( gc->gl_extension_bits, usable, sizeof( usable ) );
 }