summaryrefslogtreecommitdiff
path: root/GL
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2006-08-29 14:35:08 -0700
committerIan Romanick <idr@us.ibm.com>2006-08-29 14:35:08 -0700
commitdb6d04d4b87fd9b6409a3ddf0479a88440c2eda1 (patch)
tree7fda582ef7185b899510c0dfee4973b07407926a /GL
parent942b4369990a255257f66835caf8671432c405a3 (diff)
Add support for AIGLX drivers to enable GLX extensions that they support.
Diffstat (limited to 'GL')
-rw-r--r--GL/glx/Makefile.am4
-rw-r--r--GL/glx/extension_string.c166
-rw-r--r--GL/glx/extension_string.h63
-rw-r--r--GL/glx/glxdri.c33
4 files changed, 265 insertions, 1 deletions
diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index 339fbe04e..9bb2b7eff 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 000000000..e5899d774
--- /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@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 000000000..98e91bc18
--- /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@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 fa7f1ddc8..212f2a80c 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_modes,
}
+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);