xserver: Branch 'master' - 3 commits

Ian Romanick idr at kemper.freedesktop.org
Tue Aug 29 16:32:28 PDT 2006


 GL/glx/Makefile.am        |    4 -
 GL/glx/extension_string.c |  168 ++++++++++++++++++++++++++++++++++++++++++++++
 GL/glx/extension_string.h |   63 +++++++++++++++++
 GL/glx/glxdri.c           |   33 +++++++++
 4 files changed, 267 insertions(+), 1 deletion(-)

New commits:
diff-tree 1c8851ad491dd02d1c79e620b46384956838ed42 (from parents)
Merge: d59b52fc08f2d80b38993e383e61c3eeb0bb0763 5ddbf4bcd46fe0d3d682668c2748c712fea410ae
Author: Ian Romanick <idr at us.ibm.com>
Date:   Tue Aug 29 16:34:04 2006 -0700

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver

diff-tree d59b52fc08f2d80b38993e383e61c3eeb0bb0763 (from db6d04d4b87fd9b6409a3ddf0479a88440c2eda1)
Author: Ian Romanick <idr at us.ibm.com>
Date:   Tue Aug 29 14:40:13 2006 -0700

    Make sure unsupported extensions are disabled.
    
    GLX protocol isn't supported for GLX_SGI_swap_control or
    GLX_SGI_video_sync.  Remove them from the list of available extensions
    until they are supported.

diff --git a/GL/glx/extension_string.c b/GL/glx/extension_string.c
index e5899d7..963b18a 100644
--- a/GL/glx/extension_string.c
+++ b/GL/glx/extension_string.c
@@ -77,8 +77,10 @@ static const struct extension_info known
    { GLX(MESA_copy_sub_buffer),        VER(0,0), N, },
    { GLX(OML_swap_method),             VER(0,0), Y, },
    { GLX(SGI_make_current_read),       VER(1,3), N, },
+#if 0 /* GLX protocol not yet supported for these. */
    { GLX(SGI_swap_control),            VER(0,0), N, },
    { GLX(SGI_video_sync),              VER(0,0), N, },
+#endif
    { GLX(SGIS_multisample),            VER(0,0), Y, },
    { GLX(SGIX_fbconfig),               VER(1,3), Y, },
    { GLX(SGIX_pbuffer),                VER(1,3), N, },
diff-tree db6d04d4b87fd9b6409a3ddf0479a88440c2eda1 (from 942b4369990a255257f66835caf8671432c405a3)
Author: Ian Romanick <idr at us.ibm.com>
Date:   Tue Aug 29 14:35:08 2006 -0700

    Add support for AIGLX drivers to enable GLX extensions that they support.

diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index 339fbe0..9bb2b7e 100644
--- a/GL/glx/Makefile.am
+++ b/GL/glx/Makefile.am
@@ -31,7 +31,9 @@ INCLUDES = \
 nodist_libglx_la_SOURCES = indirect_size.h
 
 libglxdri_la_SOURCES = \
-        glxdri.c
+        glxdri.c \
+        extension_string.c \
+        extension_string.h
 
 libglx_la_SOURCES = \
         g_disptab.h \
diff --git a/GL/glx/extension_string.c b/GL/glx/extension_string.c
new file mode 100644
index 0000000..e5899d7
--- /dev/null
+++ b/GL/glx/extension_string.c
@@ -0,0 +1,166 @@
+/*
+ * (C) Copyright IBM Corporation 2002-2006
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file extension_string.c
+ * Routines to manage the GLX extension string and GLX version for AIGLX
+ * drivers.  This code is loosely based on src/glx/x11/glxextensions.c from
+ * Mesa.
+ *
+ * \author Ian Romanick <idr at us.ibm.com>
+ */
+
+#include <string.h>
+#include "extension_string.h"
+
+#define SET_BIT(m,b)    (m[ (b) / 8 ] |=  (1U << ((b) % 8)))
+#define CLR_BIT(m,b)    (m[ (b) / 8 ] &= ~(1U << ((b) % 8)))
+#define IS_SET(m,b)    ((m[ (b) / 8 ] &   (1U << ((b) % 8))) != 0)
+#define CONCAT(a,b) a ## b
+#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit)
+#define VER(a,b)  a, b
+#define Y  1
+#define N  0
+#define EXT_ENABLED(bit,supported) (IS_SET(supported, bit))
+
+struct extension_info {
+    const char * const name;
+    unsigned   name_len;
+
+    unsigned char  bit;
+
+    /**
+     * This is the lowest version of GLX that "requires" this extension.
+     * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
+     * SGI_make_current_read.  If the extension is not required by any known
+     * version of GLX, use 0, 0.
+     */
+    unsigned char  version_major;
+    unsigned char  version_minor;
+
+    /**
+     * Is driver supported foced by the ABI?
+     */
+    unsigned char  driver_support;
+};
+
+static const struct extension_info known_glx_extensions[] = {
+/*   GLX_ARB_get_proc_address is implemented on the client. */
+   { GLX(ARB_multisample),             VER(1,4), Y, },
+
+   { GLX(EXT_import_context),          VER(0,0), Y, },
+   { GLX(EXT_texture_from_pixmap),     VER(0,0), N, },
+   { GLX(EXT_visual_info),             VER(0,0), Y, },
+   { GLX(EXT_visual_rating),           VER(0,0), Y, },
+
+   { GLX(MESA_copy_sub_buffer),        VER(0,0), N, },
+   { GLX(OML_swap_method),             VER(0,0), Y, },
+   { GLX(SGI_make_current_read),       VER(1,3), N, },
+   { GLX(SGI_swap_control),            VER(0,0), N, },
+   { GLX(SGI_video_sync),              VER(0,0), N, },
+   { GLX(SGIS_multisample),            VER(0,0), Y, },
+   { GLX(SGIX_fbconfig),               VER(1,3), Y, },
+   { GLX(SGIX_pbuffer),                VER(1,3), N, },
+   { GLX(SGIX_visual_select_group),    VER(0,0), Y, },
+   { NULL }
+};
+
+
+/**
+ * Create a GLX extension string for a set of enable bits.
+ *
+ * Creates a GLX extension string for the set of bit in \c enable_bits.  This
+ * string is then stored in \c buffer if buffer is not \c NULL.  This allows
+ * two-pass operation.  On the first pass the caller passes \c NULL for
+ * \c buffer, and the function determines how much space is required to store
+ * the extension string.  The caller allocates the buffer and calls the
+ * function again.
+ *
+ * \param enable_bits  Bits representing the enabled extensions.
+ * \param buffer       Buffer to store the extension string.  May be \c NULL.
+ *
+ * \return
+ * The number of characters in \c buffer that were written to.  If \c buffer
+ * is \c NULL, this is the size of buffer that must be allocated by the
+ * caller.
+ */
+int
+__glXGetExtensionString(const unsigned char *enable_bits, char *buffer)
+{
+    unsigned i;
+    int length = 0;
+
+
+    for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+	const unsigned bit = known_glx_extensions[i].bit;
+	const size_t len = known_glx_extensions[i].name_len;
+
+	if (EXT_ENABLED(bit, enable_bits)) {
+	    if (buffer != NULL) {
+		(void) memcpy(& buffer[length], known_glx_extensions[i].name,
+			      len);
+		
+		buffer[length + len + 0] = ' ';
+		buffer[length + len + 1] = '\0';
+	    }
+
+	    length += len + 1;
+	}
+    }
+
+    return length + 1;
+}
+
+
+void
+__glXEnableExtension(unsigned char *enable_bits, const char *ext)
+{
+    const size_t ext_name_len = strlen(ext);
+    unsigned i;
+
+
+    for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+	if ((ext_name_len == known_glx_extensions[i].name_len)
+	    && (memcmp(ext, known_glx_extensions[i].name, ext_name_len) == 0)) {
+	    SET_BIT(enable_bits, known_glx_extensions[i].bit);
+	    break;
+	}
+    }
+}
+
+
+void
+__glXInitExtensionEnableBits(unsigned char *enable_bits)
+{
+    unsigned i;
+
+
+    (void) memset(enable_bits, 0, __GLX_EXT_BYTES);
+
+    for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+	if (known_glx_extensions[i].driver_support) {
+	    SET_BIT(enable_bits, known_glx_extensions[i].bit);
+	}
+    }
+}
diff --git a/GL/glx/extension_string.h b/GL/glx/extension_string.h
new file mode 100644
index 0000000..98e91bc
--- /dev/null
+++ b/GL/glx/extension_string.h
@@ -0,0 +1,63 @@
+/*
+ * (C) Copyright IBM Corporation 2002-2006
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file extension_string.h
+ * Routines to manage the GLX extension string and GLX version for AIGLX
+ * drivers.  This code is loosely based on src/glx/x11/glxextensions.c from
+ * Mesa.
+ *
+ * \author Ian Romanick <idr at us.ibm.com>
+ */
+
+#ifndef GLX_EXTENSION_STRING_H
+#define GLX_EXTENSION_STRING_H
+
+enum {
+/*   GLX_ARB_get_proc_address is implemented on the client. */
+   ARB_multisample_bit = 0,
+   EXT_import_context_bit,
+   EXT_texture_from_pixmap_bit,
+   EXT_visual_info_bit,
+   EXT_visual_rating_bit,
+   MESA_copy_sub_buffer_bit,
+   OML_swap_method_bit,
+   SGI_make_current_read_bit,
+   SGI_swap_control_bit,
+   SGI_video_sync_bit,
+   SGIS_multisample_bit,
+   SGIX_fbconfig_bit,
+   SGIX_pbuffer_bit,
+   SGIX_visual_select_group_bit,
+   __NUM_GLX_EXTS,
+};
+
+#define __GLX_EXT_BYTES ((__NUM_GLX_EXTS + 7) / 8)
+
+extern int __glXGetExtensionString(const unsigned char *enable_bits,
+    char *buffer);
+extern void __glXEnableExtension(unsigned char *enable_bits, const char *ext);
+extern void __glXInitExtensionEnableBits(unsigned char *enable_bits);
+
+#endif /* GLX_EXTENSION_STRING_H */
diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index fa7f1dd..212f2a8 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -57,6 +57,7 @@
 #include "glapi.h"
 #include "glthread.h"
 #include "dispatch.h"
+#include "extension_string.h"
 
 
 #define STRINGIFY(macro_or_string)	STRINGIFY_ARG (macro_or_string)
@@ -71,6 +72,8 @@ struct __GLXDRIscreen {
 
     __DRIscreen			 driScreen;
     void			*driver;
+
+    unsigned char glx_enable_bits[__GLX_EXT_BYTES];
 };
 
 struct __GLXDRIcontext {
@@ -586,8 +589,21 @@ filter_modes(__GLcontextModes **server_m
 }
 
 
+static void
+enable_glx_extension(void *psc, const char *ext_name)
+{
+    __GLXDRIscreen * const screen = (__GLXDRIscreen *) psc;
+
+    __glXEnableExtension(screen->glx_enable_bits, ext_name);
+}
+
+
 static __DRIfuncPtr getProcAddress(const char *proc_name)
 {
+    if (strcmp(proc_name, "glxEnableExtension") == 0) {
+	return (__DRIfuncPtr) enable_glx_extension;
+    }
+
     return NULL;
 }
 
@@ -812,6 +828,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     void *dev_priv = NULL;
     char filename[128];
     Bool isCapable;
+    size_t buffer_size;
 
     if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable")) {
 	LogMessage(X_ERROR, "AIGLX: DRI module not loaded\n");
@@ -834,6 +851,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
     screen->base.createDrawable = __glXDRIscreenCreateDrawable;
     screen->base.pScreen       = pScreen;
 
+    __glXInitExtensionEnableBits(screen->glx_enable_bits);
+    screen->driScreen.screenConfigs = screen;
+
+
     /* DRI protocol version. */
     dri_version.major = XF86DRI_MAJOR_VERSION;
     dri_version.minor = XF86DRI_MINOR_VERSION;
@@ -977,6 +998,18 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
 
     __glXScreenInit(&screen->base, pScreen);
 
+    buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
+    if (buffer_size > 0) {
+	if (screen->base.GLXextensions != NULL) {
+	    xfree(screen->base.GLXextensions);
+	}
+
+	screen->base.GLXextensions = xnfalloc(buffer_size);
+	(void) __glXGetExtensionString(screen->glx_enable_bits, 
+				       screen->base.GLXextensions);
+    }
+
+
     filter_modes(&screen->base.modes, driver_modes);
     _gl_context_modes_destroy(driver_modes);
 



More information about the xorg-commit mailing list