diff options
author | Kristian Høgsberg <krh@redhat.com> | 2006-03-12 00:11:34 +0000 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2006-03-12 00:11:34 +0000 |
commit | c3342c8000f6d2bfb61e2cf95e028d11b59698fa (patch) | |
tree | 854fa59122eff885f4f5bcf2300bdf69b5bb2b8f | |
parent | b1b731c28630965d9e2defe62d1108270dc8264c (diff) |
Merge accel_indirect branch to HEAD.
52 files changed, 2718 insertions, 3942 deletions
@@ -1,3 +1,121 @@ +2006-03-10 Kristian Høgsberg <krh@redhat.com> + + * Merge accel_indirect branch to HEAD. + +2006-03-05 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxcmds.c (DoGetDrawableAttributes): Add + GLX_Y_INVERTED_EXT to the drawable attributes we report. + +2006-03-05 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxcmds.c (__glXCreateARGBConfig): Create the fbconfig + for the composite 32 visual after the fact here. + + * GL/glx/glxdri.c (__glXDRIbindTexImage): Use 4bpp for 32 bit + visuals too, but only fill the alpha channel for 24 depth + drawables. + +2006-03-03 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxdri.c (getDrawableInfo): Work around i915 driver that + tries to render to drawable even if it no longer exists. + Returning 0 cliprects (as dri_util.c does) doesn't seem to do it, + so we set the width and height to 0. + + * GL/glx/g_disptab.h: + * GL/glx/glxcmdsswap.c: Fix a couple of warnings. + +2006-03-03 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxdri.c (__glXDRIscreenProbe): Log full DRI driver path + when dlopen() fails. + + * GL/glx/glxscreens.c (__glXInitScreens): Log the provider name + when we initialize a GLX screen. + + * GL/symlink-mesa.sh: + * GL/mesa/swrast/Makefile.am: Update to work with mesa head. + +2006-03-01 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * GL/glx/glxdri.c: (__glXDRIscreenProbe): + Pass err_msg when dev_priv allocation fails. + +2006-03-01 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxdri.c (__glXDRIscreenProbe): Handle failing allocation + of dev_priv. + + * GL/glx/glxdri.c (__glXDRIscreenProbe): The DRI driver + _mesa_free()'s the dev_priv passed in so we need to give it a + copy. + +2006-03-01 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * GL/glx/glxserver.h: + Fix Xvfb, Xnest and Xprt build. + +2006-02-28 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxdri.c (__glXDRIscreenProbe): Fix enter/leave confusion. + + * configure.ac: + * hw/xfree86/common/xf86Config.c (configServerFlags): Enable AIGLX + by default at configure time and at runtime. + +2006-02-27 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxserver.h: + * GL/glx/glxext.c: + * GL/mesa/X/xf86glx.c: Complete the prepare/finish dispatch to + enter/leave server rename. + + * GL/glx/glxcmdsswap.c (__glXSwapGetDrawableAttributesSGIX): Add + byte swapping function. + + * GL/mesa/swrast/Makefile.am (INCLUDES): Add -I../shader/slang. + + * GL/glx/glxcmds.c: Make GLX_EXT_texture_from_pixmap entrypoints + non-static so we can get at them from glxcmdsswap.c. + +2006-02-25 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxcmds.c: Add more GLX_EXT_texture_from_pixmap tokens + here as a temporary fix. + +2006-02-24 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxcmds.c: + * GL/glx/glxcmdsswap.c: + * GL/glx/glxcontext.h: + * GL/glx/glxdri.c: + * GL/glx/glxscreens.c: + * GL/glx/glxserver.h: Add hooks for GLX_EXT_texture_from_pixmap + and port over naive glTexImage2D implementation. Add support for + glXQueryDrawable. + +2006-02-24 Kevin E. Martin <kem-at-freedesktop-dot-org> + + * GL/glx/Makefile.am: + Include from Mesa sources before any installed versions. + + * GL/glx/glxdri.c: (__glXDRIleaveServer), (__glXDRIenterServer), + (createContext), (destroyContext), (createDrawable), + (destroyDrawable), (getDrawableInfo), (__glXDRIscreenProbe): + Wrap the __DRIinterfaceMethods methods with enter/leaveServer to + make sure server locks are held when calling into the card driver. + +2006-02-24 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/glxdri.c: + * GL/glx/glxvisuals.c: Add these files. + +2006-02-24 Kristian Høgsberg <krh@redhat.com> + + * GL/glx/*: Land rewritten accelerated indirect rendering on + accel_indirect_branch. + 2006-03-10 Alan Coopersmith <alan.coopersmith@sun.com> * hw/xfree86/utils/xorgcfg/help.c: diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am index db2708335..7892dd9e5 100644 --- a/GL/glx/Makefile.am +++ b/GL/glx/Makefile.am @@ -1,10 +1,16 @@ -noinst_LTLIBRARIES = libglx.la +if AIGLX +GLXDRI_LIBRARY = libglxdri.la +endif + +noinst_LTLIBRARIES = libglx.la $(GLXDRI_LIBRARY) AM_CFLAGS = \ + -I@MESA_SOURCE@/include \ @DIX_CFLAGS@ \ @GL_CFLAGS@ \ @XLIB_CFLAGS@ \ - -I@MESA_SOURCE@/include \ + @LIBDRM_CFLAGS@ \ + @DRIPROTO_CFLAGS@ \ -I@MESA_SOURCE@/src/mesa/glapi \ -I@MESA_SOURCE@/src/mesa/main \ @SERVER_DEFINES@ \ @@ -15,10 +21,20 @@ AM_CFLAGS = \ # none yet #sdk_HEADERS = -INCLUDES = -I$(top_srcdir)/GL/include -I$(top_srcdir)/hw/xfree86/os-support +INCLUDES = \ + -I$(top_srcdir)/GL/include \ + -I$(top_srcdir)/hw/xfree86/os-support \ + -I$(top_srcdir)/hw/xfree86/os-support/bus \ + -I$(top_srcdir)/hw/xfree86/common \ + -I$(top_srcdir)/hw/xfree86/dri \ + -I$(top_srcdir)/mi + nodist_libglx_la_SOURCES = indirect_size.h +libglxdri_la_SOURCES = \ + glxdri.c + libglx_la_SOURCES = \ g_disptab.c \ g_disptab.h \ @@ -29,8 +45,6 @@ libglx_la_SOURCES = \ glcontextmodes.h \ global.c \ glthread.c \ - glxbuf.c \ - glxbuf.h \ glxcmds.c \ glxcmdsswap.c \ glxcontext.h \ @@ -38,14 +52,7 @@ libglx_la_SOURCES = \ glxerror.h \ glxext.c \ glxext.h \ - glxfb.c \ - glxfb.h \ - glximports.c \ - glximports.h \ - glxmem.c \ - glxmem.h \ - glxpix.c \ - glxpix.h \ + glxvisuals.c \ glxscreens.c \ glxscreens.h \ glxserver.h \ diff --git a/GL/glx/g_disptab.h b/GL/glx/g_disptab.h index 222c5164e..9ae901c1d 100644 --- a/GL/glx/g_disptab.h +++ b/GL/glx/g_disptab.h @@ -46,6 +46,9 @@ extern int __glXWaitGL(__GLXclientState*, GLbyte*); extern int __glXWaitX(__GLXclientState*, GLbyte*); extern int __glXCopyContext(__GLXclientState*, GLbyte*); extern int __glXSwapBuffers(__GLXclientState*, GLbyte*); +extern int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc); +extern int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc); +extern int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc); extern int __glXUseXFont(__GLXclientState*, GLbyte*); extern int __glXCreateGLXPixmap(__GLXclientState*, GLbyte*); extern int __glXGetVisualConfigs(__GLXclientState*, GLbyte*); @@ -71,6 +74,9 @@ extern int __glXSwapWaitGL(__GLXclientState*, GLbyte*); extern int __glXSwapWaitX(__GLXclientState*, GLbyte*); extern int __glXSwapCopyContext(__GLXclientState*, GLbyte*); extern int __glXSwapSwapBuffers(__GLXclientState*, GLbyte*); +extern int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLbyte *pc); +extern int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc); +extern int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc); extern int __glXSwapUseXFont(__GLXclientState*, GLbyte*); extern int __glXSwapCreateGLXPixmap(__GLXclientState*, GLbyte*); extern int __glXSwapGetVisualConfigs(__GLXclientState*, GLbyte*); diff --git a/GL/glx/global.c b/GL/glx/global.c index 18cd5edc2..28030ec03 100644 --- a/GL/glx/global.c +++ b/GL/glx/global.c @@ -53,6 +53,7 @@ __GLXcontext *__glXLastContext; RESTYPE __glXContextRes; RESTYPE __glXClientRes; RESTYPE __glXPixmapRes; +RESTYPE __glXDrawableRes; RESTYPE __glXSwapBarrierRes; /* diff --git a/GL/glx/glxbuf.c b/GL/glx/glxbuf.c deleted file mode 100644 index 44be53614..000000000 --- a/GL/glx/glxbuf.c +++ /dev/null @@ -1,296 +0,0 @@ -/* $XFree86: xc/programs/Xserver/GL/glx/glxbuf.c,v 1.6 2001/03/25 05:32:01 tsi Exp $ */ -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "glxserver.h" -#include "glxutil.h" -#include "glxbuf.h" -#include "glxfb.h" -#include "glxmem.h" -#include "glxpix.h" - -void -__glXFBInitDrawable(__GLXdrawablePrivate *glxPriv, __GLcontextModes *modes) -{ - __GLdrawablePrivate *glPriv; - GLint rgbBits; - GLint accumBits; - - glPriv = &glxPriv->glPriv; - rgbBits = modes->rgbBits; - accumBits = modes->accumRedBits + modes->accumGreenBits + - modes->accumBlueBits + modes->accumAlphaBits; - -#if defined(__GL_ALIGNED_BUFFERS) - /* initialize pixel alignments (for more details see context.h) */ - glPriv->xAlignment = 1; - glPriv->yAlignment = 1; -#endif - - glxPriv->swapBuffers = __glXFBMemSwapBuffers; - - glPriv->yInverted = GL_TRUE; /* Y is upside-down */ - - if (modes->doubleBufferMode) { - if (modes->colorIndexMode) { - __glXInitFB(&glPriv->frontBuffer, glPriv, modes->indexBits); - __glXInitMem(&glPriv->backBuffer, glPriv, modes->indexBits); - } else { - __glXInitFB(&glPriv->frontBuffer, glPriv, rgbBits); - __glXInitMem(&glPriv->backBuffer, glPriv, rgbBits); - } - } else { - if (modes->colorIndexMode) { - __glXInitFB(&glPriv->frontBuffer, glPriv, modes->indexBits); - } else { - __glXInitFB(&glPriv->frontBuffer, glPriv, rgbBits); - } - } - -#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0) - if (modes->maxAuxBuffers > 0) { - GLint i; - - for (i=0; i < modes->maxAuxBuffers; i++) { - if (modes->colorIndexMode) { - __glXInitMem(&glPriv->auxBuffer[i], glPriv, modes->indexBits); - } else { - __glXInitMem(&glPriv->auxBuffer[i], glPriv, rgbBits); - } - } - } -#endif - - if (modes->haveAccumBuffer) { - __glXInitMem(&glPriv->accumBuffer, glPriv, accumBits); - } - if (modes->haveDepthBuffer) { - __glXInitMem(&glPriv->depthBuffer, glPriv, modes->depthBits); - } - if (modes->haveStencilBuffer) { - __glXInitMem(&glPriv->stencilBuffer, glPriv, modes->stencilBits); - } -} - -void -__glXPixInitDrawable(__GLXdrawablePrivate *glxPriv, __GLcontextModes *modes) -{ - __GLdrawablePrivate *glPriv; - GLint rgbBits; - GLint accumBits; - - assert(glxPriv->pGlxPixmap); - - glPriv = &glxPriv->glPriv; - rgbBits = modes->rgbBits; - accumBits = modes->accumRedBits + modes->accumGreenBits + - modes->accumBlueBits + modes->accumAlphaBits; - -#if defined(__GL_ALIGNED_BUFFERS) - /* initialize pixel alignments (for more details see context.h) */ - glPriv->xAlignment = 1; - glPriv->yAlignment = 1; -#endif - - glxPriv->swapBuffers = (GLboolean (*)(__GLXdrawablePrivate *))__glXNop; - - glPriv->yInverted = GL_FALSE; - - if (modes->doubleBufferMode) { - if (modes->colorIndexMode) { - __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits, - glxPriv->drawId, glxPriv->pGlxPixmap); - __glXInitMem(&glPriv->backBuffer, glPriv, modes->indexBits); - } else { - __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits, - glxPriv->drawId, glxPriv->pGlxPixmap); - __glXInitMem(&glPriv->backBuffer, glPriv, rgbBits); - } - } else { - if (modes->colorIndexMode) { - __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits, - glxPriv->drawId, glxPriv->pGlxPixmap); - } else { - __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits, - glxPriv->drawId, glxPriv->pGlxPixmap); - } - } - -#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0) - if (modes->maxAuxBuffers > 0) { - GLint i; - - for (i=0; i < modes->maxAuxBuffers; i++) { - if (modes->colorIndexMode) { - __glXInitMem(&glPriv->auxBuffer[i], glPriv, modes->indexBits); - } else { - __glXInitMem(&glPriv->auxBuffer[i], glPriv, rgbBits); - } - } - } -#endif - - if (modes->haveAccumBuffer) { - __glXInitMem(&glPriv->accumBuffer, glPriv, accumBits); - } - if (modes->haveDepthBuffer) { - __glXInitMem(&glPriv->depthBuffer, glPriv, modes->depthBits); - } - if (modes->haveStencilBuffer) { - __glXInitMem(&glPriv->stencilBuffer, glPriv, modes->stencilBits); - } -} - - -#define __GLX_SET_ACCEL_BUFFER_MASK(bm) \ - if (status == GL_FALSE) return GL_FALSE; \ - if (status == GL_TRUE) accelBufferMask |= bm; \ - /* for __GL_BUFFER_FALLBACK don't do anything */ - -GLboolean -__glXResizeBuffers(__GLdrawablePrivate *glPriv, - GLint x, GLint y, GLuint width, GLuint height) -{ - __GLcontextModes *modes; - __GLdrawableRegion *glRegion; - GLboolean status; - GLuint accelBufferMask; - - modes = glPriv->modes; - accelBufferMask = 0; - - status = (*glPriv->frontBuffer.resize)(&glPriv->frontBuffer, - x, y, width, height, glPriv, - __GL_FRONT_BUFFER_MASK); - __GLX_SET_ACCEL_BUFFER_MASK(__GL_FRONT_BUFFER_MASK); - - if (modes->doubleBufferMode) { - status = (*glPriv->backBuffer.resize)(&glPriv->backBuffer, - x, y, width, height, glPriv, - __GL_BACK_BUFFER_MASK); - __GLX_SET_ACCEL_BUFFER_MASK(__GL_BACK_BUFFER_MASK); - } - -#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0) - if (modes->maxAuxBuffers > 0) { - GLint i; - - for (i=0; i < modes->maxAuxBuffers; i++) { - status = (*glPriv->auxBuffers[i].resize)(&glPriv->auxBuffer[i], - x, y, width, height, - glPriv, - __GL_AUX_BUFFER_MASK(i)); - __GLX_SET_ACCEL_BUFFER_MASK(__GL_AUX_BUFFER_MASK(i)); - } - } -#endif - - if (modes->haveAccumBuffer) { - status = (*glPriv->accumBuffer.resize)(&glPriv->accumBuffer, - x, y, width, height, glPriv, - __GL_ACCUM_BUFFER_MASK); - __GLX_SET_ACCEL_BUFFER_MASK(__GL_ACCUM_BUFFER_MASK); - } - - if (modes->haveDepthBuffer) { - status = (*glPriv->depthBuffer.resize)(&glPriv->depthBuffer, - x, y, width, height, glPriv, - __GL_DEPTH_BUFFER_MASK); - __GLX_SET_ACCEL_BUFFER_MASK(__GL_DEPTH_BUFFER_MASK); - } - - if (modes->haveStencilBuffer) { - status = (*glPriv->stencilBuffer.resize)(&glPriv->stencilBuffer, - x, y, width, height, glPriv, - __GL_STENCIL_BUFFER_MASK); - __GLX_SET_ACCEL_BUFFER_MASK(__GL_STENCIL_BUFFER_MASK); - } - - glPriv->accelBufferMask = accelBufferMask; - - /* finally, update the ownership region */ - glRegion = &glPriv->ownershipRegion; - glRegion->numRects = 1; - glRegion->rects[0].x0 = 0; - glRegion->rects[0].y0 = 0; - glRegion->rects[0].x1 = width; - glRegion->rects[0].y1 = height; - - return GL_TRUE; -} - -void -__glXFreeBuffers(__GLXdrawablePrivate *glxPriv) -{ - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; -#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0) - __GLcontextModes *modes = glPriv->modes; -#endif - - if (glPriv->frontBuffer.free) { - (*glPriv->frontBuffer.free)(&glPriv->frontBuffer, glPriv); - } - if (glPriv->backBuffer.free) { - (*glPriv->backBuffer.free)(&glPriv->backBuffer, glPriv); - } - -#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0) - if (modes->maxAuxBuffers > 0) { - GLint i; - - for (i=0; i < modes->maxAuxBuffers; i++) { - if (glPriv->auxBuffer[i].free) { - (*glPriv->auxBuffer[i].free)(&glPriv->auxBuffer[i], glPriv); - } - } - } -#endif - - if (glPriv->accumBuffer.free) { - (*glPriv->accumBuffer.free)(&glPriv->accumBuffer, glPriv); - } - - if (glPriv->depthBuffer.free) { - (*glPriv->depthBuffer.free)(&glPriv->depthBuffer, glPriv); - } - - if (glPriv->stencilBuffer.free) { - (*glPriv->stencilBuffer.free)(&glPriv->stencilBuffer, glPriv); - } -} diff --git a/GL/glx/glxbuf.h b/GL/glx/glxbuf.h deleted file mode 100644 index 88b04e8bd..000000000 --- a/GL/glx/glxbuf.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $XFree86$ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _glxbuf_h_ -#define _glxbuf_h_ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -extern void __glXFBInitDrawable(__GLXdrawablePrivate *glxPriv, - __GLcontextModes *modes); -extern void __glXPixInitDrawable(__GLXdrawablePrivate *glxPriv, - __GLcontextModes *modes); - -extern GLboolean __glXResizeBuffers(__GLdrawablePrivate *glPriv, - GLint x, GLint y, - GLuint width, GLuint height); - -extern void __glXFreeBuffers(__GLXdrawablePrivate *glxPriv); -extern void __glXUpdatePalette(__GLXdrawablePrivate *); - -#endif /* _glxbuf_h_ */ - diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index c63b17008..6426e294e 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -49,7 +49,6 @@ #include <pixmapstr.h> #include <windowstr.h> #include "g_disptab_EXT.h" -#include "glximports.h" #include "glxutil.h" #include "glxext.h" #include "GL/glx_ansic.h" @@ -61,24 +60,6 @@ /************************************************************************/ -static __GLimports imports = { - __glXImpMalloc, - __glXImpCalloc, - __glXImpRealloc, - __glXImpFree, - __glXImpWarning, - __glXImpFatal, - __glXImpGetenv, - __glXImpAtoi, - __glXImpSprintf, - __glXImpFopen, - __glXImpFclose, - __glXImpFprintf, - __glXImpGetDrawablePrivate, - __glXImpGetReadablePrivate, - NULL -}; - static int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc); static int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc); static int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc); @@ -94,6 +75,27 @@ static int __glxHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc); /************************************************************************/ +static void __glXdirectContextDestroy(__GLXcontext *context) +{ + __glXFree(context); +} + +static __GLXcontext *__glXdirectContextCreate(__GLXscreen *screen, + __GLcontextModes *modes, + __GLXcontext *shareContext) +{ + __GLXcontext *context; + + context = __glXMalloc (sizeof (__GLXcontext)); + if (context == NULL) + return NULL; + + memset(context, 0, sizeof *context); + context->destroy = __glXdirectContextDestroy; + + return context; +} + /** * Create a GL context with the given properties. This routine is used * to implement \c glXCreateContext, \c glXCreateNewContext, and @@ -111,8 +113,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, ScreenPtr pScreen; __GLXcontext *glxc, *shareglxc; __GLcontextModes *modes; - __GLXscreenInfo *pGlxScreen; - __GLinterface *shareGC; + __GLXscreen *pGlxScreen; GLint i; LEGAL_NEW_RESOURCE(gcId, client); @@ -125,7 +126,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, return BadValue; } pScreen = screenInfo.screens[screen]; - pGlxScreen = &__glXActiveScreens[screen]; + pGlxScreen = __glXActiveScreens[screen]; /* ** Check if the visual ID is valid for this screen. @@ -167,7 +168,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, ** for multithreaded servers, we don't do this. */ if (shareList == None) { - shareGC = 0; + shareglxc = 0; } else { shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes); if (!shareglxc) { @@ -193,17 +194,18 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, */ isDirect = GL_FALSE; } - shareGC = shareglxc->gc; } /* ** Allocate memory for the new context */ - glxc = (__GLXcontext *) __glXMalloc(sizeof(__GLXcontext)); + if (!isDirect) + glxc = pGlxScreen->createContext(pGlxScreen, modes, shareglxc); + else + glxc = __glXdirectContextCreate(pGlxScreen, modes, shareglxc); if (!glxc) { return BadAlloc; } - __glXMemset(glxc, 0, sizeof(__GLXcontext)); /* ** Initially, setup the part of the context that could be used by @@ -214,32 +216,11 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, glxc->pVisual = pVisual; glxc->modes = modes; - if (!isDirect) { - - /* - ** Allocate a GL context - */ - imports.other = (void *)glxc; - glxc->gc = (*pGlxScreen->createContext)(&imports, glxc->modes, shareGC); - if (!glxc->gc) { - __glXFree(glxc); - client->errorValue = gcId; - return BadAlloc; - } - } else { - /* - ** Don't need local GL context for a direct context. - */ - glxc->gc = 0; - } /* ** Register this context as a resource. */ if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) { - if (!isDirect) { - (*glxc->gc->exports.destroyContext)((__GLcontext *)glxc->gc); - } - __glXFree(glxc); + (*glxc->destroy)(glxc); client->errorValue = gcId; return BadAlloc; } @@ -520,9 +501,8 @@ int DoMakeCurrent( __GLXclientState *cl, __GLXpixmap *drawPixmap = NULL; __GLXpixmap *readPixmap = NULL; __GLXcontext *glxc, *prevglxc; - __GLinterface *gc, *prevgc; - __GLXdrawablePrivate *drawPriv = NULL; - __GLXdrawablePrivate *readPriv = NULL; + __GLXdrawable *drawPriv = NULL; + __GLXdrawable *readPriv = NULL; GLint error; GLuint mask; @@ -554,10 +534,8 @@ int DoMakeCurrent( __GLXclientState *cl, client->errorValue = prevglxc->id; return __glXBadContextState; } - prevgc = prevglxc->gc; } else { prevglxc = 0; - prevgc = 0; } /* @@ -575,8 +553,6 @@ int DoMakeCurrent( __GLXclientState *cl, /* Context is current to somebody else */ return BadAccess; } - gc = glxc->gc; - assert( drawId != None ); assert( readId != None ); @@ -600,14 +576,14 @@ int DoMakeCurrent( __GLXclientState *cl, /* FIXME: Finish refactoring this. - idr */ /* get the drawable private */ if (pDraw) { - drawPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes); + drawPriv = __glXGetDrawable(glxc, pDraw, drawId); if (drawPriv == NULL) { return __glXBadDrawable; } } if (pRead != pDraw) { - readPriv = __glXGetDrawablePrivate(pRead, readId, glxc->modes); + readPriv = __glXGetDrawable(glxc, pRead, readId); if (readPriv == NULL) { return __glXBadDrawable; } @@ -618,7 +594,6 @@ int DoMakeCurrent( __GLXclientState *cl, } else { /* Switching to no context. Ignore new drawable. */ glxc = 0; - gc = 0; pDraw = 0; pRead = 0; } @@ -640,7 +615,7 @@ int DoMakeCurrent( __GLXclientState *cl, /* ** Make the previous context not current. */ - if (!(*prevgc->exports.loseCurrent)((__GLcontext *)prevgc)) { + if (!(*prevglxc->loseCurrent)(prevglxc)) { return __glXBadContext; } __glXDeassociateContext(prevglxc); @@ -651,19 +626,18 @@ int DoMakeCurrent( __GLXclientState *cl, glxc->drawPriv = drawPriv; glxc->readPriv = readPriv; - __glXCacheDrawableSize(drawPriv); /* make the context current */ - if (!(*gc->exports.makeCurrent)((__GLcontext *)gc)) { + if (!(*glxc->makeCurrent)(glxc)) { glxc->drawPriv = NULL; glxc->readPriv = NULL; return __glXBadContext; } /* resize the buffers */ - if (!__glXResizeDrawableBuffers(drawPriv)) { + if (!(*drawPriv->resize)(drawPriv)) { /* could not do initial resize. make current failed */ - (*gc->exports.loseCurrent)((__GLcontext *)gc); + (*glxc->loseCurrent)(glxc); glxc->drawPriv = NULL; glxc->readPriv = NULL; return __glXBadContext; @@ -911,9 +885,7 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc) /* ** Issue copy. The only reason for failure is a bad mask. */ - if (!(*dst->gc->exports.copyContext)((__GLcontext *)dst->gc, - (__GLcontext *)src->gc, - mask)) { + if (!(*dst->copy)(dst, src, mask)) { client->errorValue = mask; return BadValue; } @@ -926,7 +898,7 @@ int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen, { ClientPtr client = cl->client; xGLXGetVisualConfigsReply reply; - __GLXscreenInfo *pGlxScreen; + __GLXscreen *pGlxScreen; __GLcontextModes *modes; CARD32 buf[__GLX_TOTAL_CONFIG]; int p; @@ -938,7 +910,7 @@ int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen, client->errorValue = screen; return BadValue; } - pGlxScreen = &__glXActiveScreens[screen]; + pGlxScreen = __glXActiveScreens[screen]; reply.numVisuals = pGlxScreen->numUsableVisuals; reply.numProps = __GLX_TOTAL_CONFIG; @@ -1017,6 +989,68 @@ int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc) } +/* Composite adds a 32 bit ARGB visual after glxvisuals.c have created + * the context modes for the screens. This visual is useful for GLX + * pixmaps, so we create a single mode for this visual with no extra + * buffers. */ +static void +__glXCreateARGBConfig(__GLXscreen *screen) +{ + __GLcontextModes *modes; + VisualPtr visual; + int i; + + visual = NULL; + for (i = 0; i < screen->pScreen->numVisuals; i++) + if (screen->pScreen->visuals[i].nplanes == 32) { + visual = &screen->pScreen->visuals[i]; + break; + } + + if (visual == NULL || visual->class != TrueColor) + return; + + if (_gl_context_modes_find_visual (screen->modes, visual->vid)) + return; + + /* Stop now if we already added the mode. */ + modes = _gl_context_modes_create(1, sizeof(__GLcontextModes)); + if (modes == NULL) + return; + + modes->next = screen->modes; + screen->modes = modes; + screen->numUsableVisuals++; + screen->numVisuals++; + + modes->visualID = visual->vid; + modes->fbconfigID = visual->vid; + modes->visualType = GLX_TRUE_COLOR; + modes->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT; + modes->renderType = GLX_RGBA_BIT; + modes->xRenderable = GL_TRUE; + modes->rgbMode = TRUE; + modes->colorIndexMode = FALSE; + modes->doubleBufferMode = FALSE; + modes->stereoMode = FALSE; + modes->haveAccumBuffer = FALSE; + + modes->redBits = visual->bitsPerRGBValue;; + modes->greenBits = visual->bitsPerRGBValue; + modes->blueBits = visual->bitsPerRGBValue; + modes->alphaBits = visual->bitsPerRGBValue; + + modes->rgbBits = 4 * visual->bitsPerRGBValue; + modes->indexBits = 0; + modes->level = 0; + modes->numAuxBuffers = 0; + + modes->haveDepthBuffer = FALSE; + modes->depthBits = 0; + modes->haveStencilBuffer = FALSE; + modes->stencilBits = 0; +} + #define __GLX_TOTAL_FBCONFIG_ATTRIBS (28) #define __GLX_FBCONFIG_ATTRIBS_LENGTH (__GLX_TOTAL_FBCONFIG_ATTRIBS * 2) @@ -1034,7 +1068,7 @@ int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap) { ClientPtr client = cl->client; xGLXGetFBConfigsReply reply; - __GLXscreenInfo *pGlxScreen; + __GLXscreen *pGlxScreen; CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH]; int p; __GLcontextModes *modes; @@ -1047,7 +1081,9 @@ int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap) client->errorValue = screen; return BadValue; } - pGlxScreen = &__glXActiveScreens[screen]; + pGlxScreen = __glXActiveScreens[screen]; + + __glXCreateARGBConfig(pGlxScreen); reply.numFBConfigs = pGlxScreen->numUsableVisuals; reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS; @@ -1145,7 +1181,7 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual, ScreenPtr pScreen; VisualPtr pVisual; __GLXpixmap *pGlxPixmap; - __GLXscreenInfo *pGlxScreen; + __GLXscreen *pGlxScreen; __GLcontextModes *modes; int i; @@ -1188,7 +1224,7 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual, /* ** Get configuration of the visual. */ - pGlxScreen = &__glXActiveScreens[screenNum]; + pGlxScreen = __glXActiveScreens[screenNum]; modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual ); if (modes == NULL) { /* @@ -1339,16 +1375,16 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) } if (pDraw) { - __GLXdrawablePrivate *glxPriv; + __GLXdrawable *glxPriv; if (glxc) { - glxPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes); + glxPriv = __glXGetDrawable(glxc, pDraw, drawId); if (glxPriv == NULL) { return __glXBadDrawable; } } else { - glxPriv = __glXFindDrawablePrivate(drawId); + glxPriv = __glXFindDrawable(drawId); if (glxPriv == NULL) { /* This is a window we've never seen before, do nothing */ return Success; @@ -1412,6 +1448,136 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) } +int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc) +{ + xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; + ClientPtr client = cl->client; + __GLXpixmap *pGlxPixmap; + __GLXcontext *context; + GLXDrawable drawId; + int buffer; + int error; + + pc += __GLX_VENDPRIV_HDR_SIZE; + + drawId = *((CARD32 *) (pc)); + buffer = *((INT32 *) (pc + 4)); + + if (buffer != GLX_FRONT_LEFT_EXT) + return __glXBadPixmap; + + context = __glXForceCurrent (cl, req->contextTag, &error); + if (!context) + return error; + + pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes); + if (!pGlxPixmap) { + client->errorValue = drawId; + return __glXBadPixmap; + } + + if (!context->textureFromPixmap) + return __glXUnsupportedPrivateRequest; + + return context->textureFromPixmap->bindTexImage(context, + buffer, + pGlxPixmap); +} + +int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) +{ + xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; + ClientPtr client = cl->client; + __GLXpixmap *pGlxPixmap; + __GLXcontext *context; + GLXDrawable drawId; + int buffer; + int error; + + pc += __GLX_VENDPRIV_HDR_SIZE; + + drawId = *((CARD32 *) (pc)); + buffer = *((INT32 *) (pc + 4)); + + context = __glXForceCurrent (cl, req->contextTag, &error); + if (!context) + return error; + + pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes); + if (!pGlxPixmap) { + client->errorValue = drawId; + return __glXBadDrawable; + } + + if (!context->textureFromPixmap) + return __glXUnsupportedPrivateRequest; + + return context->textureFromPixmap->releaseTexImage(context, + buffer, + pGlxPixmap); +} + +#ifndef GLX_TEXTURE_TARGET_EXT +#define GLX_TEXTURE_TARGET_EXT 0x6001 +#define GLX_TEXTURE_2D_EXT 0x6002 +#define GLX_TEXTURE_RECTANGLE_EXT 0x6003 +#define GLX_NO_TEXTURE_EXT 0x6004 +#define GLX_Y_INVERTED_EXT 0x6006 +#endif + +/* +** Get drawable attributes +*/ +static int +DoGetDrawableAttributes(__GLXclientState *cl, XID drawId) +{ + ClientPtr client = cl->client; + __GLXpixmap *glxPixmap; + xGLXGetDrawableAttributesReply reply; + CARD32 attributes[2]; + int numAttribs; + + glxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes); + if (!glxPixmap) { + client->errorValue = drawId; + return __glXBadPixmap; + } + + numAttribs = 2; + reply.length = numAttribs << 1; + reply.type = X_Reply; + reply.sequenceNumber = client->sequence; + reply.numAttribs = numAttribs; + + attributes[0] = GLX_TEXTURE_TARGET_EXT; + attributes[1] = GLX_TEXTURE_RECTANGLE_EXT; + attributes[2] = GLX_Y_INVERTED_EXT; + attributes[3] = GL_FALSE; + + if (client->swapped) { + __glXSwapGetDrawableAttributesReply(client, &reply, attributes); + } else { + WriteToClient(client, sz_xGLXGetDrawableAttributesReply, + (char *)&reply); + WriteToClient(client, reply.length * sizeof (CARD32), + (char *)attributes); + } + + return Success; +} + +int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc; + CARD32 *data; + XID drawable; + + data = (CARD32 *) (req + 1); + drawable = data[0]; + + return DoGetDrawableAttributes(cl, drawable); +} + /************************************************************************/ /* @@ -1985,6 +2151,10 @@ int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc) return Success; case X_GLXvop_BindSwapBarrierSGIX: return __glXBindSwapBarrierSGIX(cl, pc); + case X_GLXvop_BindTexImageEXT: + return __glXBindTexImageEXT(cl, pc); + case X_GLXvop_ReleaseTexImageEXT: + return __glXReleaseTexImageEXT(cl, pc); } #endif @@ -2030,6 +2200,8 @@ int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) return __glXCreateContextWithConfigSGIX(cl, pc); case X_GLXvop_CreateGLXPixmapWithConfigSGIX: return __glXCreateGLXPixmapWithConfigSGIX(cl, pc); + case X_GLXvop_GetDrawableAttributesSGIX: + return __glXGetDrawableAttributesSGIX(cl, pc); default: break; } @@ -2064,7 +2236,7 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc) return BadValue; } - ptr = __glXActiveScreens[screen].GLXextensions; + ptr = __glXActiveScreens[screen]->GLXextensions; n = __glXStrlen(ptr) + 1; length = __GLX_PAD(n) >> 2; @@ -2111,13 +2283,13 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc) } switch(name) { case GLX_VENDOR: - ptr = __glXActiveScreens[screen].GLXvendor; + ptr = __glXActiveScreens[screen]->GLXvendor; break; case GLX_VERSION: - ptr = __glXActiveScreens[screen].GLXversion; + ptr = __glXActiveScreens[screen]->GLXversion; break; case GLX_EXTENSIONS: - ptr = __glXActiveScreens[screen].GLXextensions; + ptr = __glXActiveScreens[screen]->GLXextensions; break; default: return BadValue; diff --git a/GL/glx/glxcmdsswap.c b/GL/glx/glxcmdsswap.c index 5729cf851..e14106913 100644 --- a/GL/glx/glxcmdsswap.c +++ b/GL/glx/glxcmdsswap.c @@ -40,6 +40,7 @@ #include <dix-config.h> #endif +#include <string.h> #include "glxserver.h" #include "glxutil.h" #include <GL/glxtokens.h> @@ -389,6 +390,64 @@ int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) return __glXQueryContextInfoEXT(cl, pc); } +int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLbyte *pc) +{ + xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; + GLXDrawable *drawId; + int *buffer; + + __GLX_DECLARE_SWAP_VARIABLES; + + pc += __GLX_VENDPRIV_HDR_SIZE; + + drawId = ((GLXDrawable *) (pc)); + buffer = ((int *) (pc + 4)); + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->contextTag); + __GLX_SWAP_INT(drawId); + __GLX_SWAP_INT(buffer); + + return __glXBindTexImageEXT(cl, (GLbyte *)pc); +} + +int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) +{ + xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc; + GLXDrawable *drawId; + int *buffer; + + __GLX_DECLARE_SWAP_VARIABLES; + + pc += __GLX_VENDPRIV_HDR_SIZE; + + drawId = ((GLXDrawable *) (pc)); + buffer = ((int *) (pc + 4)); + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->contextTag); + __GLX_SWAP_INT(drawId); + __GLX_SWAP_INT(buffer); + + return __glXReleaseTexImageEXT(cl, (GLbyte *)pc); +} + +int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) +{ + xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc; + CARD32 *data; + + __GLX_DECLARE_SWAP_VARIABLES; + + data = (CARD32 *) (req + 1); + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->contextTag); + __GLX_SWAP_INT(data); + + return __glXGetDrawableAttributesSGIX(cl, (GLbyte *)pc); +} + + /************************************************************************/ /* @@ -463,6 +522,19 @@ void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXT WriteToClient(client, length << 2, (char *)buf); } +void __glXSwapGetDrawableAttributesReply(ClientPtr client, + xGLXGetDrawableAttributesReply *reply, CARD32 *buf) +{ + int length = reply->length; + __GLX_DECLARE_SWAP_VARIABLES; + __GLX_DECLARE_SWAP_ARRAY_VARIABLES; + __GLX_SWAP_SHORT(&reply->sequenceNumber); + __GLX_SWAP_INT(&reply->length); + __GLX_SWAP_INT(&reply->numAttribs); + WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)reply); + __GLX_SWAP_INT_ARRAY((int *)buf, length); + WriteToClient(client, length << 2, (char *)buf); +} /************************************************************************/ @@ -824,6 +896,10 @@ int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(pc + 4); CALL_SamplePatternSGIS( GET_DISPATCH(), (*(GLenum *)(pc + 4)) ); return Success; + case X_GLXvop_BindTexImageEXT: + return __glXSwapBindTexImageEXT(cl, pc); + case X_GLXvop_ReleaseTexImageEXT: + return __glXSwapReleaseTexImageEXT(cl, pc); } #endif @@ -861,6 +937,8 @@ int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) return __glXSwapCreateContextWithConfigSGIX(cl, pc); case X_GLXvop_CreateGLXPixmapWithConfigSGIX: return __glXSwapCreateGLXPixmapWithConfigSGIX(cl, pc); + case X_GLXvop_GetDrawableAttributesSGIX: + return __glXSwapGetDrawableAttributesSGIX(cl, pc); default: break; } diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h index 18d8b44c2..5c27aa0b8 100644 --- a/GL/glx/glxcontext.h +++ b/GL/glx/glxcontext.h @@ -41,32 +41,48 @@ ** */ -typedef struct __GLXcontextRec __GLXcontext; - /* XXX: should be defined somewhere globally */ #define CAPI #include "GL/internal/glcore.h" -struct __GLXcontextRec { +typedef struct __GLXtextureFromPixmap __GLXtextureFromPixmap; +struct __GLXtextureFromPixmap { + int (*bindTexImage) (__GLXcontext *baseContext, + int buffer, + __GLXpixmap *pixmap); + int (*releaseTexImage) (__GLXcontext *baseContext, + int buffer, + __GLXpixmap *pixmap); +}; + + +struct __GLXcontext { + void (*destroy) (__GLXcontext *context); + int (*makeCurrent) (__GLXcontext *context); + int (*loseCurrent) (__GLXcontext *context); + int (*copy) (__GLXcontext *dst, + __GLXcontext *src, + unsigned long mask); + int (*forceCurrent) (__GLXcontext *context); + + __GLXdrawable *(*createDrawable)(__GLXcontext *context, + DrawablePtr pDraw, + XID drawId); + + __GLXtextureFromPixmap *textureFromPixmap; + /* ** list of context structs */ - struct __GLXcontextRec *last; - struct __GLXcontextRec *next; + __GLXcontext *last; + __GLXcontext *next; /* ** list of contexts bound to the same drawable */ - struct __GLXcontextRec *nextDrawPriv; - struct __GLXcontextRec *nextReadPriv; - - /* - ** Opaque pointer the context object created by the GL that the - ** server is bound with. Never dereferenced by this code, but used - ** as a handle to feed to the routines in the screen info struct. - */ - __GLinterface *gc; + __GLXcontext *nextDrawPriv; + __GLXcontext *nextReadPriv; /* ** mode struct for this context @@ -78,7 +94,7 @@ struct __GLXcontextRec { ** when the context is created. */ ScreenPtr pScreen; - __GLXscreenInfo *pGlxScreen; + __GLXscreen *pGlxScreen; /* ** This context is created with respect to this visual. @@ -152,8 +168,8 @@ struct __GLXcontextRec { /* ** The drawable private this context is bound to */ - __GLXdrawablePrivate *drawPriv; - __GLXdrawablePrivate *readPriv; + __GLXdrawable *drawPriv; + __GLXdrawable *readPriv; }; /* pending state defines */ diff --git a/GL/glx/glxdrawable.h b/GL/glx/glxdrawable.h index 38a05bfeb..2d5d07a79 100644 --- a/GL/glx/glxdrawable.h +++ b/GL/glx/glxdrawable.h @@ -45,19 +45,23 @@ typedef struct { DrawablePtr pDraw; __GLcontextModes *modes; - __GLXscreenInfo *pGlxScreen; + __GLXscreen *pGlxScreen; ScreenPtr pScreen; Bool idExists; int refcnt; } __GLXpixmap; -struct __GLXdrawablePrivateRec { +struct __GLXdrawable { + void (*destroy)(__GLXdrawable *private); + GLboolean (*resize)(__GLXdrawable *private); + GLboolean (*swapBuffers)(__GLXdrawable *); + /* ** list of drawable private structs */ - struct __GLXdrawablePrivateRec *last; - struct __GLXdrawablePrivateRec *next; + __GLXdrawable *last; + __GLXdrawable *next; DrawablePtr pDraw; XID drawId; @@ -76,32 +80,13 @@ struct __GLXdrawablePrivateRec { __GLcontextModes *modes; /* - ** cached drawable size and origin - */ - - GLint xorigin, yorigin; - GLint width, height; - - /* ** Lists of contexts bound to this drawable. There are two lists here. ** One list is of the contexts that have this drawable bound for drawing, ** and the other is the list of contexts that have this drawable bound ** for reading. */ - struct __GLXcontextRec *drawGlxc; - struct __GLXcontextRec *readGlxc; - - /* - ** "methods" that the drawble should be able to respond to. - */ - void (*freeBuffers)(struct __GLXdrawablePrivateRec *); - void (*updatePalette)(struct __GLXdrawablePrivateRec *); - GLboolean (*swapBuffers)(struct __GLXdrawablePrivateRec *); - - /* - ** The GL drawable (information shared between GLX and the GL core) - */ - __GLdrawablePrivate glPriv; + __GLXcontext *drawGlxc; + __GLXcontext *readGlxc; /* ** reference count diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c new file mode 100644 index 000000000..a78af1b06 --- /dev/null +++ b/GL/glx/glxdri.c @@ -0,0 +1,926 @@ +/* + * Copyright © 2006 Red Hat, Inc + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Red Hat, + * Inc not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Red Hat, Inc makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * RED HAT, INC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL RED HAT, INC BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdint.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <sys/time.h> +#include <dlfcn.h> + +#include <drm.h> +#include <GL/gl.h> +#include <GL/internal/dri_interface.h> + +#include <windowstr.h> +#include <os.h> + +#define _XF86DRI_SERVER_ +#include <drm_sarea.h> +#include <xf86drm.h> +#include <xf86dristr.h> +#include <xf86str.h> +#include <xf86.h> +#include <dri.h> + +#define DRI_NEW_INTERFACE_ONLY +#include "glxserver.h" +#include "glxutil.h" +#include "glcontextmodes.h" + +#include "g_disptab.h" +#include "g_disptab_EXT.h" +#include "glapitable.h" +#include "glapi.h" +#include "glthread.h" +#include "dispatch.h" + + +#define STRINGIFY(macro_or_string) STRINGIFY_ARG (macro_or_string) +#define STRINGIFY_ARG(contents) #contents + +typedef struct __GLXDRIscreen __GLXDRIscreen; +typedef struct __GLXDRIcontext __GLXDRIcontext; +typedef struct __GLXDRIdrawable __GLXDRIdrawable; + +struct __GLXDRIscreen { + __GLXscreen base; + + __DRIscreen driScreen; + void *driver; +}; + +struct __GLXDRIcontext { + __GLXcontext base; + + __DRIcontext driContext; +}; + +struct __GLXDRIdrawable { + __GLXdrawable base; + + __DRIdrawable *driDrawable; +}; + +/* History: + * 20021121 - Initial version + * 20021128 - Added __glXWindowExists() function + * 20021207 - Added support for dynamic GLX extensions, + * GLX_SGI_swap_control, GLX_SGI_video_sync, + * GLX_OML_sync_control, and GLX_MESA_swap_control. + * Never officially released. Do NOT test against + * this version. Use 20030317 instead. + * 20030317 - Added support GLX_SGIX_fbconfig, + * GLX_MESA_swap_frame_usage, GLX_OML_swap_method, + * GLX_{ARB,SGIS}_multisample, and + * GLX_SGIX_visual_select_group. + * 20030606 - Added support for GLX_SGI_make_current_read. + * 20030813 - Made support for dynamic extensions multi-head aware. + * 20030818 - Added support for GLX_MESA_allocate_memory in place of the + * deprecated GLX_NV_vertex_array_range & GLX_MESA_agp_offset + * interfaces. + * 20031201 - Added support for the first round of DRI interface changes. + * Do NOT test against this version! It has binary + * compatibility bugs, use 20040317 instead. + * 20040317 - Added the 'mode' field to __DRIcontextRec. + * 20040415 - Added support for bindContext3 and unbindContext3. + * 20040602 - Add __glXGetDrawableInfo. I though that was there + * months ago. :( + * 20050727 - Gut all the old interfaces. This breaks compatability with + * any DRI driver built to any previous version. + */ +#define INTERNAL_VERSION 20050727 + +static const char CREATE_NEW_SCREEN_FUNC[] = + "__driCreateNewScreen_" STRINGIFY (INTERNAL_VERSION); + +static void +__glXDRIleaveServer(void) +{ + int i; + + for (i = 0; i < screenInfo.numScreens; i++) + DRIDoBlockHandler(i, NULL, NULL, NULL); +} + +static void +__glXDRIenterServer(void) +{ + int i; + + for (i = 0; i < screenInfo.numScreens; i++) + DRIDoWakeupHandler(i, NULL, 0, NULL); +} + +static void +__glXDRIdrawableDestroy(__GLXdrawable *private) +{ +#if 0 + (*glxPriv->driDrawable.destroyDrawable)(NULL, + glxPriv->driDrawable.private); +#endif + + __glXFree(private); +} + +static GLboolean +__glXDRIdrawableResize(__GLXdrawable *glxPriv) +{ + /* Nothing to do here, the DRI driver asks the server for drawable + * geometry when it sess the SAREA timestamps change.*/ + + return GL_TRUE; +} + +static GLboolean +__glXDRIdrawableSwapBuffers(__GLXdrawable *basePrivate) +{ + __GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate; + __GLXDRIscreen *screen; + + /* FIXME: We're jumping through hoops here to get the DRIdrawable + * which the dri driver tries to keep to it self... cf. FIXME in + * createDrawable. */ + + screen = (__GLXDRIscreen *) __glXgetActiveScreen(private->base.pDraw->pScreen->myNum); + private->driDrawable = (screen->driScreen.getDrawable)(NULL, + private->base.drawId, + screen->driScreen.private); + + (*private->driDrawable->swapBuffers)(NULL, + private->driDrawable->private); + + return TRUE; +} + +static __GLXdrawable * +__glXDRIcontextCreateDrawable(__GLXcontext *context, + DrawablePtr pDraw, + XID drawId) +{ + __GLXDRIdrawable *private; + + private = __glXMalloc(sizeof *private); + if (private == NULL) + return NULL; + + memset(private, 0, sizeof *private); + + if (!__glXDrawableInit(&private->base, context, pDraw, drawId)) { + __glXFree(private); + return NULL; + } + + private->base.destroy = __glXDRIdrawableDestroy; + private->base.resize = __glXDRIdrawableResize; + private->base.swapBuffers = __glXDRIdrawableSwapBuffers; + +#if 0 + /* FIXME: It would only be natural that we called + * driScreen->createNewDrawable here but the DRI drivers manage + * them a little oddly. FIXME: describe this better.*/ + + /* The last argument is 'attrs', which is used with pbuffers which + * we currently don't support. */ + + glxPriv->driDrawable.private = + (pGlxScreen->driScreen.createNewDrawable)(NULL, modes, + drawId, + &glxPriv->driDrawable, + 0, + NULL); +#endif + + return &private->base; +} + + +static void +__glXDRIcontextDestroy(__GLXcontext *baseContext) +{ + __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext; + + context->driContext.destroyContext(NULL, + context->base.pScreen->myNum, + context->driContext.private); + __glXFree(context); +} + +static int +__glXDRIcontextMakeCurrent(__GLXcontext *baseContext) +{ + __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext; + + return (*context->driContext.bindContext)(NULL, + context->base.pScreen->myNum, + baseContext->drawPriv->drawId, + baseContext->readPriv->drawId, + &context->driContext); +} + +static int +__glXDRIcontextLoseCurrent(__GLXcontext *baseContext) +{ + __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext; + + return (*context->driContext.unbindContext)(NULL, + context->base.pScreen->myNum, + baseContext->drawPriv->drawId, + baseContext->readPriv->drawId, + &context->driContext); +} + +static int +__glXDRIcontextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, + unsigned long mask) +{ + __GLXDRIcontext *dst = (__GLXDRIcontext *) baseDst; + __GLXDRIcontext *src = (__GLXDRIcontext *) baseSrc; + + /* FIXME: We will need to add DRIcontext::copyContext for this. */ + + (void) dst; + (void) src; + + return FALSE; +} + +static int +__glXDRIcontextForceCurrent(__GLXcontext *baseContext) +{ + __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext; + + return (*context->driContext.bindContext)(NULL, + context->base.pScreen->myNum, + baseContext->drawPriv->drawId, + baseContext->readPriv->drawId, + &context->driContext); +} + +static int +glxCountBits(int word) +{ + int ret = 0; + + while (word) { + ret += (word & 1); + word >>= 1; + } + + return ret; +} + +static void +glxFillAlphaChannel (PixmapPtr pixmap) +{ + int i, j; + CARD32 *pixels = (CARD32 *)pixmap->devPrivate.ptr; + CARD32 rowstride = pixmap->devKind / 4; + CARD32 x, y; + + x = pixmap->drawable.x; + y = pixmap->drawable.y; + + for (i = y; i < pixmap->drawable.height + y; ++i) + { + for (j = x; j < pixmap->drawable.width + x; ++j) + { + int index = i * rowstride + j; + + pixels[index] |= 0xFF000000; + } + } +} + +/* + * (sticking this here for lack of a better place) + * Known issues with the GLX_EXT_texture_from_pixmap implementation: + * - In general we ignore the fbconfig, lots of examples follow + * - No fbconfig handling for multiple mipmap levels + * - No fbconfig handling for 1D textures + * - No fbconfig handling for TEXTURE_TARGET + * - No fbconfig exposure of Y inversion state + * - No GenerateMipmapEXT support (due to no FBO support) + * - No damage tracking between binds + * - No support for anything but 16bpp and 32bpp-sparse pixmaps + */ + +static int +__glXDRIbindTexImage(__GLXcontext *baseContext, + int buffer, + __GLXpixmap *glxPixmap) +{ + PixmapPtr pixmap; + int bpp; + Bool npot; + + pixmap = (PixmapPtr) glxPixmap->pDraw; + bpp = pixmap->drawable.depth >= 24 ? 4 : 2; /* XXX 24bpp packed, 8, etc */ + + CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH, + pixmap->devKind / bpp) ); + CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, + pixmap->drawable.y) ); + CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, + pixmap->drawable.x) ); + + if (pixmap->drawable.depth == 24) + glxFillAlphaChannel(pixmap); + + npot = !(glxCountBits(pixmap->drawable.width) == 1 && + glxCountBits(pixmap->drawable.height) == 1) /* || + strstr(CALL_GetString(GL_EXTENSIONS, + "GL_ARB_texture_non_power_of_two")) */ ; + + CALL_TexImage2D( GET_DISPATCH(), + ( npot ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, + 0, + bpp == 4 ? 4 : 3, + pixmap->drawable.width, + pixmap->drawable.height, + 0, + bpp == 4 ? GL_BGRA : GL_RGB, + bpp == 4 ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5, + pixmap->devPrivate.ptr ) ); + + return Success; +} + +static int +__glXDRIreleaseTexImage(__GLXcontext *baseContext, + int buffer, + __GLXpixmap *pixmap) +{ + return Success; +} + +static __GLXtextureFromPixmap __glXDRItextureFromPixmap = { + __glXDRIbindTexImage, + __glXDRIreleaseTexImage +}; + +static void +__glXDRIscreenDestroy(__GLXscreen *baseScreen) +{ + __GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen; + + screen->driScreen.destroyScreen(NULL, + screen->base.pScreen->myNum, + screen->driScreen.private); + + dlclose(screen->driver); + + __glXScreenDestroy(baseScreen); + + __glXFree(screen); +} + +static __GLXcontext * +__glXDRIscreenCreateContext(__GLXscreen *baseScreen, + __GLcontextModes *modes, + __GLXcontext *baseShareContext) +{ + __GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen; + __GLXDRIcontext *context, *shareContext; + void *sharePrivate; + + shareContext = (__GLXDRIcontext *) baseShareContext; + if (shareContext) + sharePrivate = shareContext->driContext.private; + else + sharePrivate = NULL; + + context = __glXMalloc(sizeof *context); + if (context == NULL) + return NULL; + + memset(context, 0, sizeof *context); + context->base.destroy = __glXDRIcontextDestroy; + context->base.makeCurrent = __glXDRIcontextMakeCurrent; + context->base.loseCurrent = __glXDRIcontextLoseCurrent; + context->base.copy = __glXDRIcontextCopy; + context->base.forceCurrent = __glXDRIcontextForceCurrent; + context->base.createDrawable = __glXDRIcontextCreateDrawable; + + context->base.textureFromPixmap = &__glXDRItextureFromPixmap; + + context->driContext.private = + screen->driScreen.createNewContext(NULL, modes, + 0, /* render type */ + sharePrivate, + &context->driContext); + + context->driContext.mode = modes; + + return &context->base; +} + +static unsigned +filter_modes(__GLcontextModes **server_modes, + const __GLcontextModes *driver_modes) +{ + __GLcontextModes * m; + __GLcontextModes ** prev_next; + const __GLcontextModes * check; + unsigned modes_count = 0; + + if ( driver_modes == NULL ) { + LogMessage(X_WARNING, + "AIGLX: 3D driver returned no fbconfigs.\n"); + return 0; + } + + /* For each mode in server_modes, check to see if a matching mode exists + * in driver_modes. If not, then the mode is not available. + */ + + prev_next = server_modes; + for ( m = *prev_next ; m != NULL ; m = *prev_next ) { + GLboolean do_delete = GL_TRUE; + + for ( check = driver_modes ; check != NULL ; check = check->next ) { + if ( _gl_context_modes_are_same( m, check ) ) { + do_delete = GL_FALSE; + break; + } + } + + /* The 3D has to support all the modes that match the GLX visuals + * sent from the X server. + */ + if ( do_delete && (m->visualID != 0) ) { + do_delete = GL_FALSE; + + LogMessage(X_WARNING, + "AIGLX: 3D driver claims to not support " + "visual 0x%02x\n", m->visualID); + } + + if ( do_delete ) { + *prev_next = m->next; + + m->next = NULL; + _gl_context_modes_destroy( m ); + } + else { + modes_count++; + prev_next = & m->next; + } + } + + return modes_count; +} + + +static __DRIfuncPtr getProcAddress(const char *proc_name) +{ + return NULL; +} + +static __DRIscreen *findScreen(__DRInativeDisplay *dpy, int scrn) +{ + __GLXDRIscreen *screen = + (__GLXDRIscreen *) __glXgetActiveScreen(scrn); + + return &screen->driScreen; +} + +static GLboolean windowExists(__DRInativeDisplay *dpy, __DRIid draw) +{ + WindowPtr pWin = (WindowPtr) LookupIDByType(draw, RT_WINDOW); + + return pWin == NULL ? GL_FALSE : GL_TRUE; +} + +static GLboolean createContext(__DRInativeDisplay *dpy, int screen, + int configID, void *contextID, + drm_context_t *hw_context) +{ + XID fakeID; + VisualPtr visual; + int i; + ScreenPtr pScreen; + GLboolean retval; + + pScreen = screenInfo.screens[screen]; + + /* Find the requested X visual */ + visual = pScreen->visuals; + for (i = 0; i < pScreen->numVisuals; i++, visual++) + if (visual->vid == configID) + break; + if (i == pScreen->numVisuals) + return GL_FALSE; + + fakeID = FakeClientID(0); + *(XID *) contextID = fakeID; + + __glXDRIenterServer(); + retval = DRICreateContext(pScreen, visual, fakeID, hw_context); + __glXDRIleaveServer(); + return retval; +} + +static GLboolean destroyContext(__DRInativeDisplay *dpy, int screen, + __DRIid context) +{ + GLboolean retval; + + __glXDRIenterServer(); + retval = DRIDestroyContext(screenInfo.screens[screen], context); + __glXDRIleaveServer(); + return retval; +} + +static GLboolean +createDrawable(__DRInativeDisplay *dpy, int screen, + __DRIid drawable, drm_drawable_t *hHWDrawable) +{ + DrawablePtr pDrawable; + GLboolean retval; + + pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE); + if (!pDrawable) + return GL_FALSE; + + __glXDRIenterServer(); + retval = DRICreateDrawable(screenInfo.screens[screen], + drawable, + pDrawable, + hHWDrawable); + __glXDRIleaveServer(); + return retval; +} + +static GLboolean +destroyDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable) +{ + DrawablePtr pDrawable; + GLboolean retval; + + pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE); + if (!pDrawable) + return GL_FALSE; + + __glXDRIenterServer(); + retval = DRIDestroyDrawable(screenInfo.screens[screen], + drawable, + pDrawable); + __glXDRIleaveServer(); + return retval; +} + +static GLboolean +getDrawableInfo(__DRInativeDisplay *dpy, int screen, + __DRIid drawable, unsigned int *index, unsigned int *stamp, + int *x, int *y, int *width, int *height, + int *numClipRects, drm_clip_rect_t **ppClipRects, + int *backX, int *backY, + int *numBackClipRects, drm_clip_rect_t **ppBackClipRects) +{ + DrawablePtr pDrawable; + drm_clip_rect_t *pClipRects, *pBackClipRects; + GLboolean retval; + size_t size; + + pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE); + if (!pDrawable) { + ErrorF("getDrawableInfo failed to look up window\n"); + + *index = 0; + *stamp = 0; + *x = 0; + *y = 0; + *width = 0; + *height = 0; + *numClipRects = 0; + *ppClipRects = NULL; + *backX = 0; + *backY = 0; + *numBackClipRects = 0; + *ppBackClipRects = NULL; + + return GL_FALSE; + } + + __glXDRIenterServer(); + retval = DRIGetDrawableInfo(screenInfo.screens[screen], + pDrawable, index, stamp, + x, y, width, height, + numClipRects, &pClipRects, + backX, backY, + numBackClipRects, &pBackClipRects); + __glXDRIleaveServer(); + + if (*numClipRects > 0) { + size = sizeof (drm_clip_rect_t) * *numClipRects; + *ppClipRects = __glXMalloc (size); + if (*ppClipRects != NULL) + memcpy (*ppClipRects, pClipRects, size); + } + else { + *ppClipRects = NULL; + } + + if (*numBackClipRects > 0) { + size = sizeof (drm_clip_rect_t) * *numBackClipRects; + *ppBackClipRects = __glXMalloc (size); + if (*ppBackClipRects != NULL) + memcpy (*ppBackClipRects, pBackClipRects, size); + } + else { + *ppBackClipRects = NULL; + } + + return GL_TRUE; +} + +static int +getUST(int64_t *ust) +{ + struct timeval tv; + + if (ust == NULL) + return -EFAULT; + + if (gettimeofday(&tv, NULL) == 0) { + ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec; + return 0; + } else { + return -errno; + } +} + +/* Table of functions that we export to the driver. */ +static const __DRIinterfaceMethods interface_methods = { + getProcAddress, + + _gl_context_modes_create, + _gl_context_modes_destroy, + + findScreen, + windowExists, + + createContext, + destroyContext, + + createDrawable, + destroyDrawable, + getDrawableInfo, + + getUST, + NULL, /* glXGetMscRateOML, */ +}; + +static const char dri_driver_path[] = DRI_DRIVER_PATH; + +static __GLXscreen * +__glXDRIscreenProbe(ScreenPtr pScreen) +{ + PFNCREATENEWSCREENFUNC createNewScreen; + drm_handle_t hSAREA; + drmAddress pSAREA = NULL; + char *BusID; + __DRIversion ddx_version; + __DRIversion dri_version; + __DRIversion drm_version; + __DRIframebuffer framebuffer; + int fd = -1; + int status; + const char *err_msg; + const char *err_extra = NULL; + int api_ver = INTERNAL_VERSION; + drm_magic_t magic; + drmVersionPtr version; + char *driverName; + drm_handle_t hFB; + int junk; + __GLcontextModes * driver_modes; + __GLXDRIscreen *screen; + void *dev_priv = NULL; + char filename[128]; + + screen = __glXMalloc(sizeof *screen); + if (screen == NULL) + return NULL; + memset(screen, 0, sizeof *screen); + + screen->base.destroy = __glXDRIscreenDestroy; + screen->base.createContext = __glXDRIscreenCreateContext; + screen->base.pScreen = pScreen; + + /* DRI protocol version. */ + dri_version.major = XF86DRI_MAJOR_VERSION; + dri_version.minor = XF86DRI_MINOR_VERSION; + dri_version.patch = XF86DRI_PATCH_VERSION; + + framebuffer.base = NULL; + framebuffer.dev_priv = NULL; + + if (!DRIOpenConnection(pScreen, &hSAREA, &BusID)) { + err_msg = "DRIOpenConnection"; + err_extra = NULL; + goto handle_error; + } + + fd = drmOpen(NULL, BusID); + + if (fd < 0) { + err_msg = "open DRM"; + err_extra = strerror( -fd ); + goto handle_error; + } + + if (drmGetMagic(fd, &magic)) { + err_msg = "drmGetMagic"; + goto handle_error; + } + + version = drmGetVersion(fd); + if (version) { + drm_version.major = version->version_major; + drm_version.minor = version->version_minor; + drm_version.patch = version->version_patchlevel; + drmFreeVersion(version); + } + else { + drm_version.major = -1; + drm_version.minor = -1; + drm_version.patch = -1; + } + + if (!DRIAuthConnection(pScreen, magic)) { + err_msg = "DRIAuthConnection"; + goto handle_error; + } + + /* Get device name (like "tdfx") and the ddx version numbers. + * We'll check the version in each DRI driver's "createNewScreen" + * function. */ + if (!DRIGetClientDriverName(pScreen, + &ddx_version.major, + &ddx_version.minor, + &ddx_version.patch, + &driverName)) { + err_msg = "DRIGetClientDriverName"; + goto handle_error; + } + + snprintf(filename, sizeof filename, "%s/%s_dri.so", + dri_driver_path, driverName); + + screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); + if (screen->driver == NULL) { + err_msg = "Loading driver"; + err_extra = filename; + goto handle_error; + } + + createNewScreen = dlsym(screen->driver, CREATE_NEW_SCREEN_FUNC); + if (createNewScreen == NULL) { + err_msg = "Driver entry point lookup"; + err_extra = CREATE_NEW_SCREEN_FUNC; + goto handle_error; + } + + /* + * Get device-specific info. pDevPriv will point to a struct + * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that + * has information about the screen size, depth, pitch, ancilliary + * buffers, DRM mmap handles, etc. + */ + if (!DRIGetDeviceInfo(pScreen, &hFB, &junk, + &framebuffer.size, &framebuffer.stride, + &framebuffer.dev_priv_size, &framebuffer.dev_priv)) { + err_msg = "XF86DRIGetDeviceInfo"; + goto handle_error; + } + + /* Sigh... the DRI interface is broken; the DRI driver will free + * the dev private pointer using _mesa_free() on screen destroy, + * but we can't use _mesa_malloc() here. In fact, the DRI driver + * shouldn't free data it didn't allocate itself, but what can you + * do... */ + dev_priv = __glXMalloc(framebuffer.dev_priv_size); + if (dev_priv == NULL) { + err_msg = "dev_priv allocation"; + goto handle_error; + } + memcpy(dev_priv, framebuffer.dev_priv, framebuffer.dev_priv_size); + framebuffer.dev_priv = dev_priv; + + framebuffer.width = pScreen->width; + framebuffer.height = pScreen->height; + + /* Map the framebuffer region. */ + status = drmMap(fd, hFB, framebuffer.size, + (drmAddressPtr)&framebuffer.base); + if (status != 0) { + err_msg = "drmMap of framebuffer"; + err_extra = strerror( -status ); + goto handle_error; + } + + /* Map the SAREA region. Further mmap regions may be setup in + * each DRI driver's "createNewScreen" function. + */ + status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA); + if (status != 0) { + err_msg = "drmMap of sarea"; + err_extra = strerror( -status ); + goto handle_error; + } + + driver_modes = NULL; + screen->driScreen.private = + (*createNewScreen)(NULL, pScreen->myNum, + &screen->driScreen, + screen->base.modes, + &ddx_version, + &dri_version, + &drm_version, + &framebuffer, + pSAREA, + fd, + api_ver, + &interface_methods, + &driver_modes); + + if (screen->driScreen.private == NULL) { + err_msg = "InitDriver"; + err_extra = NULL; + goto handle_error; + } + + __glXScreenInit(&screen->base, pScreen); + + filter_modes(&screen->base.modes, driver_modes); + _gl_context_modes_destroy(driver_modes); + + __glXsetEnterLeaveServerFuncs(__glXDRIenterServer, __glXDRIleaveServer); + + LogMessage(X_INFO, + "AIGLX: Loaded and initialized %s\n", filename); + + return &screen->base; + + handle_error: + if (pSAREA != NULL) + drmUnmap(pSAREA, SAREA_MAX); + + if (framebuffer.base != NULL) + drmUnmap((drmAddress)framebuffer.base, framebuffer.size); + + if (dev_priv != NULL) + __glXFree(dev_priv); + + if (fd >= 0) + drmClose(fd); + + DRICloseConnection(pScreen); + + if (screen->driver) + dlclose(screen->driver); + + xfree(screen); + + if (err_extra != NULL) + LogMessage(X_ERROR, + "AIGLX error: %s failed (%s)\n", err_msg, err_extra); + else + LogMessage(X_ERROR, "AIGLX error: %s failed\n", err_msg); + + ErrorF("GLX-DRI: reverting to software rendering\n"); + + return NULL; +} + +__GLXprovider __glXDRIProvider = { + __glXDRIscreenProbe, + "DRI", + NULL +}; diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c index fa1382983..e4ad47803 100644 --- a/GL/glx/glxext.c +++ b/GL/glx/glxext.c @@ -23,6 +23,7 @@ #include <dix-config.h> #endif +#include <string.h> #include "glxserver.h" #include <windowstr.h> #include <propertyst.h> @@ -31,19 +32,12 @@ #include "unpack.h" #include "glxutil.h" #include "glxext.h" -#include "micmap.h" - -void GlxWrapInitVisuals(miInitVisualsProcPtr *); -void GlxSetVisualConfigs(int nconfigs, - __GLXvisualConfig *configs, void **privates); - -static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */; +static Bool inDispatch; /* ** Forward declarations. */ -static int __glXSwapDispatch(ClientPtr); static int __glXDispatch(ClientPtr); /* @@ -52,8 +46,7 @@ static int __glXDispatch(ClientPtr); static void ResetExtension(ExtensionEntry* extEntry) { __glXFlushContextCache(); - (*__glXExt->resetExtension)(); - __glXScreenReset(); + __glXResetScreens(); } /* @@ -159,24 +152,64 @@ static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id) } /* +** Destroy routine that gets called when a drawable is freed. A drawable +** contains the ancillary buffers needed for rendering. +*/ +static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) +{ + __GLXcontext *cx, *cx1; + + /* + ** Use glxPriv->type to figure out what kind of drawable this is. Don't + ** use glxPriv->pDraw->type because by the time this routine is called, + ** the pDraw might already have been freed. + */ + if (glxPriv->type == DRAWABLE_WINDOW) { + /* + ** When a window is destroyed, notify all context bound to + ** it, that there are no longer bound to anything. + */ + for (cx = glxPriv->drawGlxc; cx; cx = cx1) { + cx1 = cx->nextDrawPriv; + cx->pendingState |= __GLX_PENDING_DESTROY; + } + + for (cx = glxPriv->readGlxc; cx; cx = cx1) { + cx1 = cx->nextReadPriv; + cx->pendingState |= __GLX_PENDING_DESTROY; + } + } + + __glXUnrefDrawable(glxPriv); + + return True; +} + +/* ** Free a context. */ GLboolean __glXFreeContext(__GLXcontext *cx) { if (cx->idExists || cx->isCurrent) return GL_FALSE; - if (!cx->isDirect) { - if ((*cx->gc->exports.destroyContext)((__GLcontext *)cx->gc) == GL_FALSE) { - return GL_FALSE; - } - } if (cx->feedbackBuf) __glXFree(cx->feedbackBuf); if (cx->selectBuf) __glXFree(cx->selectBuf); - __glXFree(cx); if (cx == __glXLastContext) { __glXFlushContextCache(); } + /* We can get here through both regular dispatching from + * __glXDispatch() or as a callback from the resource manager. In + * the latter case we need to lift the DRI lock manually. */ + + if (!inDispatch) + __glXleaveServer(); + + cx->destroy(cx); + + if (!inDispatch) + __glXenterServer(); + return GL_TRUE; } @@ -240,13 +273,14 @@ void GlxExtensionInit(void) __glXContextRes = CreateNewResourceType((DeleteType)ContextGone); __glXClientRes = CreateNewResourceType((DeleteType)ClientGone); __glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone); + __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone); /* ** Add extension to server extensions. */ extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS, __GLX_NUMBER_ERRORS, __glXDispatch, - __glXSwapDispatch, ResetExtension, + __glXDispatch, ResetExtension, StandardMinorOpcode); if (!extEntry) { FatalError("__glXExtensionInit: AddExtensions failed\n"); @@ -280,53 +314,7 @@ void GlxExtensionInit(void) /* ** Initialize screen specific data. */ - __glXScreenInit(screenInfo.numScreens); -} - -/************************************************************************/ - -Bool __glXCoreType(void) -{ - return __glXExt->type; -} - -/************************************************************************/ - -void GlxSetVisualConfigs(int nconfigs, - __GLXvisualConfig *configs, void **privates) -{ - (*__glXExt->setVisualConfigs)(nconfigs, configs, privates); -} - -static miInitVisualsProcPtr saveInitVisualsProc; - -Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, - int *rootDepthp, VisualID *defaultVisp, - unsigned long sizes, int bitsPerRGB, - int preferredVis) -{ - Bool ret; - - if (saveInitVisualsProc) { - ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp, - rootDepthp, defaultVisp, sizes, bitsPerRGB, - preferredVis); - if (!ret) - return False; - } - (*__glXExt->initVisuals)(visualp, depthp, nvisualp, ndepthp, rootDepthp, - defaultVisp, sizes, bitsPerRGB); - return True; -} - -void -GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc) -{ - saveInitVisualsProc = *initVisProc; - *initVisProc = GlxInitVisuals; - /* HACK: this shouldn't be done here but it's the earliest time */ - __glXExt = __glXglDDXExtensionInfo(); /* from GLcore */ + __glXInitScreens(); } /************************************************************************/ @@ -377,7 +365,7 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag, /* Make this context the current one for the GL. */ if (!cx->isDirect) { - if (!(*cx->gc->exports.forceCurrent)((__GLcontext *)cx->gc)) { + if (!(*cx->forceCurrent)(cx)) { /* Bind failed, and set the error code. Bummer */ cl->client->errorValue = cx->id; *error = __glXBadContextState; @@ -393,12 +381,51 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag, /* ** Top level dispatcher; all commands are executed from here down. */ + +/* I cried when I wrote this. Damn you XAA! */ + +static void +__glXnopEnterServer(void) +{ +} + +static void +__glXnopLeaveServer(void) +{ +} + +static void (*__glXenterServerFunc)(void) = __glXnopEnterServer; +static void (*__glXleaveServerFunc)(void) = __glXnopLeaveServer; + +void __glXsetEnterLeaveServerFuncs(void (*enter)(void), + void (*leave)(void)) +{ + __glXenterServerFunc = enter; + __glXleaveServerFunc = leave; +} + + +void __glXenterServer(void) +{ + (*__glXenterServerFunc)(); +} + +void __glXleaveServer(void) +{ + (*__glXleaveServerFunc)(); +} + + +/* +** Top level dispatcher; all commands are executed from here down. +*/ static int __glXDispatch(ClientPtr client) { REQUEST(xGLXSingleReq); CARD8 opcode; int (*proc)(__GLXclientState *cl, GLbyte *pc); __GLXclientState *cl; + int retval; opcode = stuff->glxCode; cl = __glXClients[client->index]; @@ -443,54 +470,22 @@ static int __glXDispatch(ClientPtr client) /* ** Use the opcode to index into the procedure table. */ - proc = __glXSingleTable[opcode]; - return (*proc)(cl, (GLbyte *) stuff); -} + if (client->swapped) + proc = __glXSwapSingleTable[opcode]; + else + proc = __glXSingleTable[opcode]; -static int __glXSwapDispatch(ClientPtr client) -{ - REQUEST(xGLXSingleReq); - CARD8 opcode; - int (*proc)(__GLXclientState *cl, GLbyte *pc); - __GLXclientState *cl; + __glXleaveServer(); - opcode = stuff->glxCode; - cl = __glXClients[client->index]; - if (!cl) { - cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState)); - __glXClients[client->index] = cl; - if (!cl) { - return BadAlloc; - } - __glXMemset(cl, 0, sizeof(__GLXclientState)); - } - - if (!cl->inUse) { - /* - ** This is first request from this client. Associate a resource - ** with the client so we will be notified when the client dies. - */ - XID xid = FakeClientID(client->index); - if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) { - return BadAlloc; - } - ResetClientState(client->index); - cl->inUse = GL_TRUE; - cl->client = client; - } + inDispatch = True; - /* - ** Check for valid opcode. - */ - if (opcode >= __GLX_SINGLE_TABLE_SIZE) { - return BadRequest; - } + retval = proc(cl, (GLbyte *) stuff); - /* - ** Use the opcode to index into the procedure table. - */ - proc = __glXSwapSingleTable[opcode]; - return (*proc)(cl, (GLbyte *) stuff); + inDispatch = False; + + __glXenterServer(); + + return retval; } int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc) diff --git a/GL/glx/glxfb.c b/GL/glx/glxfb.c deleted file mode 100644 index 0d433d25d..000000000 --- a/GL/glx/glxfb.c +++ /dev/null @@ -1,183 +0,0 @@ -/* $XFree86$ */ -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -/* -** An implementation of a buffer which is part of the front buffer -*/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "glxserver.h" -#include "glxutil.h" -#include "glxfb.h" - -#include <gcstruct.h> - -/* so we don't include glmath.h */ -extern GLuint __glFloorLog2(GLuint); - -typedef struct __GLFBbufferInfoRec { - GCPtr pGC; -} __GLFBbufferInfo; - -extern PixmapPtr __glXPrivPixGetPtr(__GLdrawableBuffer *); - -/* ---------------------------------------------------------- */ - -static GLboolean -Resize(__GLdrawableBuffer *buf, - GLint x, GLint y, GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, GLuint bufferMask) -{ - buf->width = width; - buf->height = height; - buf->byteWidth = width * buf->elementSize; - buf->outerWidth = width; - - return GL_TRUE; -} - -static void -Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ -} - -static void -Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ -} - -/* -** Do a swap buffer with -** a memory surface as a back buffer -** a FB surface as a front buffer -*/ -GLboolean -__glXFBMemSwapBuffers(__GLXdrawablePrivate *glxPriv) -{ - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; - __GLdrawableBuffer *front = &glPriv->frontBuffer; - __GLdrawableBuffer *back = &glPriv->backBuffer; - __GLFBbufferInfo *bufferInfo; - GCPtr pGC; - GLint width, height, depth, pad; - GLubyte *buf; - - bufferInfo = (__GLFBbufferInfo *) front->other; - pGC = bufferInfo->pGC; - - width = back->width; - height = back->height; - depth = back->depth; - buf = back->base; - pad = back->outerWidth - back->width; /* back buffer padding */ - /* adjust buffer padding. X wants left, GL has right */ - buf -= pad; - - ValidateGC(glxPriv->pDraw, pGC); - (*pGC->ops->PutImage)(glxPriv->pDraw, pGC, - depth, - 0, 0, width, height, - pad, ZPixmap, - (char *)buf); - - return GL_TRUE; -} - -static void -Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ - __GLFBbufferInfo *bufferInfo; - - bufferInfo = (__GLFBbufferInfo *) buf->other; - - if (bufferInfo->pGC) { - FreeScratchGC(bufferInfo->pGC); - } - - __glXFree(bufferInfo); - buf->other = NULL; -} - -/* -** function to return the X GC of this buffer (to be used by DDX) -*/ -GCPtr __glXFBGetGC(__GLdrawableBuffer *buf) -{ - __GLFBbufferInfo *bufferInfo; - - bufferInfo = (__GLFBbufferInfo *) buf->other; - - if (bufferInfo) { - return bufferInfo->pGC; - } else { - return NULL; - } -} - - -void -__glXInitFB(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, GLint bits) -{ - __GLFBbufferInfo *bufferInfo; - __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *) glPriv->other; - GCPtr pGC; - - buf->depth = bits; - buf->width = buf->height = 0; /* to be filled during Update */ - buf->handle = buf->base = NULL; /* to be filled during Update */ - buf->size = 0; - buf->byteWidth = 0; - buf->elementSize = ((bits-1) / 8) + 1; - buf->elementSizeLog2 = __glFloorLog2(buf->elementSize); - - buf->resize = Resize; - buf->lock = Lock; - buf->unlock = Unlock; - buf->fill = NULL; - buf->free = Free; - - /* allocate local information */ - bufferInfo = (__GLFBbufferInfo *) __glXMalloc(sizeof(__GLFBbufferInfo)); - buf->other = (void *) bufferInfo; - - pGC = CreateScratchGC(glxPriv->pDraw->pScreen, - glxPriv->pDraw->depth); - bufferInfo->pGC = pGC; - (*pGC->funcs->ChangeClip)(pGC, CT_NONE, NULL, 0); -} diff --git a/GL/glx/glxfb.h b/GL/glx/glxfb.h deleted file mode 100644 index 325146d43..000000000 --- a/GL/glx/glxfb.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $XFree86$ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _glxfb_h_ -#define _glxfb_h_ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -extern void __glXInitFB(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, - GLint bits); - -extern GCPtr __glXFBGetGC(__GLdrawableBuffer *buf); - -extern GLboolean __glXFBMemSwapBuffers(__GLXdrawablePrivate *glxPriv); - -#endif /* _glxfb_h_ */ - diff --git a/GL/glx/glximports.c b/GL/glx/glximports.c deleted file mode 100644 index a443495c4..000000000 --- a/GL/glx/glximports.c +++ /dev/null @@ -1,188 +0,0 @@ -/* $XFree86: xc/programs/Xserver/GL/glx/glximports.c,v 1.5 2001/03/21 16:29:36 dawes Exp $ */ -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "glxserver.h" -#include "glxcontext.h" -#include "glximports.h" -#include "GL/glx_ansic.h" - -void *__glXImpMalloc(__GLcontext *gc, size_t size) -{ - void *addr; - - if (size == 0) { - return NULL; - } - addr = xalloc(size); - if (addr == NULL) { - /* XXX: handle out of memory error */ - return NULL; - } - return addr; -} - -void *__glXImpCalloc(__GLcontext *gc, size_t numElements, size_t elementSize) -{ - void *addr; - size_t size; - - if ((numElements == 0) || (elementSize == 0)) { - return NULL; - } - size = numElements * elementSize; - addr = xalloc(size); - if (addr == NULL) { - /* XXX: handle out of memory error */ - return NULL; - } - /* zero out memory */ - __glXMemset(addr, 0, size); - - return addr; -} - -void __glXImpFree(__GLcontext *gc, void *addr) -{ - if (addr) { - xfree(addr); - } -} - -void *__glXImpRealloc(__GLcontext *gc, void *addr, size_t newSize) -{ - void *newAddr; - - if (addr) { - if (newSize == 0) { - xfree(addr); - return NULL; - } - newAddr = xrealloc(addr, newSize); - } else { - if (newSize == 0) { - return NULL; - } - newAddr = xalloc(newSize); - } - if (newAddr == NULL) { - return NULL; /* XXX: out of memory error */ - } - - return newAddr; -} - -void __glXImpWarning(__GLcontext *gc, char *msg) -{ - ErrorF((char *)msg); -} - -void __glXImpFatal(__GLcontext *gc, char *msg) -{ - ErrorF((char *)msg); - __glXAbort(); -} - -char *__glXImpGetenv(__GLcontext *gc, const char *var) -{ - return __glXGetenv(var); -} - -int __glXImpAtoi(__GLcontext *gc, const char *str) -{ - return __glXAtoi(str); -} - -int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...) -{ - va_list ap; - int ret; - - /* have to deal with var args */ - va_start(ap, fmt); - ret = __glXVsprintf(str, fmt, ap); - va_end(ap); - - return ret; -} - -void *__glXImpFopen(__GLcontext *gc, const char *path, const char *mode) -{ - return (void *) __glXFopen(path, mode); -} - -int __glXImpFclose(__GLcontext *gc, void *stream) -{ - return __glXFclose((FILE *)stream); -} - -int __glXImpFprintf(__GLcontext *gc, void *stream, const char *fmt, ...) -{ - va_list ap; - int ret; - - /* have to deal with var args */ - va_start(ap, fmt); - ret = __glXVfprintf((FILE *)stream, fmt, ap); - va_end(ap); - - return ret; -} - - -__GLdrawablePrivate *__glXImpGetDrawablePrivate(__GLcontext *gc) -{ - __GLinterface *glci = (__GLinterface *) gc; - __GLXcontext *glrc = (__GLXcontext *) glci->imports.other; - - return &glrc->drawPriv->glPriv; -} - - -__GLdrawablePrivate *__glXImpGetReadablePrivate(__GLcontext *gc) -{ - __GLinterface *glci = (__GLinterface *) gc; - __GLXcontext *glrc = (__GLXcontext *) glci->imports.other; - - return &glrc->readPriv->glPriv; -} diff --git a/GL/glx/glximports.h b/GL/glx/glximports.h deleted file mode 100644 index ef485822e..000000000 --- a/GL/glx/glximports.h +++ /dev/null @@ -1,66 +0,0 @@ -/* $XFree86: xc/programs/Xserver/GL/glx/glximports.h,v 1.3 2001/03/21 16:29:36 dawes Exp $ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _glximports_h_ -#define _glximports_h_ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -extern void *__glXImpMalloc(__GLcontext *gc, size_t size); -extern void *__glXImpCalloc(__GLcontext *gc, size_t nElem, size_t eSize); -extern void *__glXImpRealloc(__GLcontext *gc, void *addr, size_t newSize); -extern void __glXImpFree(__GLcontext *gc, void *addr); - -extern void __glXImpWarning(__GLcontext *gc, char *msg); -extern void __glXImpFatal(__GLcontext *gc, char *msg); - -extern char *__glXImpGetenv(__GLcontext *gc, const char *var); -extern int __glXImpAtoi(__GLcontext *gc, const char *str); -extern int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...); -extern void *__glXImpFopen(__GLcontext *gc, const char *path, - const char *mode); -extern int __glXImpFclose(__GLcontext *gc, void *stream); -extern int __glXImpFprintf(__GLcontext *gc, void *stream, - const char *fmt, ...); - -extern __GLdrawablePrivate *__glXImpGetDrawablePrivate(__GLcontext *gc); -extern __GLdrawablePrivate *__glXImpGetReadablePrivate(__GLcontext *gc); - - -#endif /* _glximports_h_ */ - diff --git a/GL/glx/glxmem.c b/GL/glx/glxmem.c deleted file mode 100644 index 21a7c7962..000000000 --- a/GL/glx/glxmem.c +++ /dev/null @@ -1,151 +0,0 @@ -/* $XFree86: xc/programs/Xserver/GL/glx/glxmem.c,v 1.6 2001/10/31 22:50:27 tsi Exp $ */ -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -/* -** Implementation of a buffer in main memory -*/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "glxserver.h" -#include "glxmem.h" -#include "glxext.h" -#include "GL/internal/glcore.h" - -/* don't want to include glmath.h */ -extern GLuint __glFloorLog2(GLuint); - -/* ---------------------------------------------------------- */ - -#define BUF_ALIGN 32 /* x86 cache alignment (used for assembly paths) */ -#define BUF_ALIGN_MASK (BUF_ALIGN-1) - -static GLboolean -Resize(__GLdrawableBuffer *buf, - GLint x, GLint y, GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, GLuint bufferMask) -{ - GLuint newSize; - void *ubase; - GLint pixelWidth; - GLint alignedWidth; - - /* - ** Note: - ** buf->handle : unaligned base - ** buf->base : aligned base - */ - - pixelWidth = BUF_ALIGN / buf->elementSize; - alignedWidth = (width & ~(pixelWidth-1)) + pixelWidth; - - newSize = alignedWidth * height * buf->elementSize; - - /* - ** Only allocate buffer space for the SGI core. - ** Mesa and Aqua handle their own buffer allocations. - */ -#if defined(__GL_BUFFER_SIZE_TRACKS_WINDOW) - if (__glXCoreType() == GL_CORE_SGI) { -#else - if (newSize > buf->size && __glXCoreType() == GL_CORE_SGI) { -#endif - if (buf->handle) { - ubase = (*glPriv->realloc)(buf->handle, newSize + BUF_ALIGN_MASK); - if (ubase == NULL) { - return GL_FALSE; - } - } else { - ubase = (*glPriv->malloc)(newSize + BUF_ALIGN_MASK); - if (ubase == NULL) { - return GL_FALSE; - } - } - buf->size = newSize; - - buf->handle = ubase; - buf->base = (void *)(((size_t)ubase + BUF_ALIGN_MASK) & - (unsigned int) ~BUF_ALIGN_MASK); - assert(((size_t)buf->base % BUF_ALIGN) == 0); - } - - buf->width = width; - buf->height = height; - buf->byteWidth = alignedWidth * buf->elementSize; - buf->outerWidth = alignedWidth; - - return GL_TRUE; -} - -static void -Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ -} - -static void -Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ -} - -static void -Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ - if (buf->handle) { - (*glPriv->free)(buf->handle); - buf->handle = NULL; - } -} - - -void -__glXInitMem(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, GLint bits) -{ - buf->width = buf->height = 0; /* to be filled during Update */ - buf->depth = bits; - buf->size = 0; - buf->handle = buf->base = NULL; /* to be filled during Update */ - buf->byteWidth = 0; - buf->elementSize = ((bits - 1) / 8) + 1; - buf->elementSizeLog2 = __glFloorLog2(buf->elementSize); - - buf->resize = Resize; - buf->lock = Lock; - buf->unlock = Unlock; - buf->fill = NULL; - buf->free = Free; -} diff --git a/GL/glx/glxmem.h b/GL/glx/glxmem.h deleted file mode 100644 index 06720dfdf..000000000 --- a/GL/glx/glxmem.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $XFree86$ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _glxmem_h_ -#define _glxmem_h_ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -extern void __glXInitMem(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, - GLint bits); - -#endif /* _glxmem_h_ */ - diff --git a/GL/glx/glxpix.c b/GL/glx/glxpix.c deleted file mode 100644 index 98c033c98..000000000 --- a/GL/glx/glxpix.c +++ /dev/null @@ -1,132 +0,0 @@ -/* $XFree86: xc/programs/Xserver/GL/glx/glxpix.c,v 1.3 2000/09/26 15:57:02 tsi Exp $ */ -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -/* -** An implementation of a glx pixmap buffer -*/ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include "glxserver.h" -#include "glxutil.h" -#include "glxpix.h" - -#include <gcstruct.h> - -/* don't want to include glmath.h */ -extern GLuint __glFloorLog2(GLuint); - -typedef struct __GLPixBufferInfoRec { - GCPtr pGC; -} __GLPixBufferInfo; - -/* ---------------------------------------------------------- */ - -static GLboolean -Resize(__GLdrawableBuffer *buf, - GLint x, GLint y, GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, GLuint bufferMask) -{ - buf->width = width; - buf->height = width; - buf->byteWidth = width * buf->elementSize; - buf->outerWidth = width; - - return GL_TRUE; -} - -static void -Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ -} - -static void -Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ -} - -static void -Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv) -{ - __GLPixBufferInfo *bufferInfo; - - if (LookupIDByType((XID)(long)buf->handle, __glXPixmapRes)) { - FreeResource((XID)(long)buf->handle, FALSE); - buf->handle = NULL; - } - - bufferInfo = (__GLPixBufferInfo *) buf->other; - - if (bufferInfo->pGC) { - FreeScratchGC(bufferInfo->pGC); - } - - __glXFree(bufferInfo); - buf->other = NULL; -} - -void -__glXInitPix(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, - GLint bits, XID glxpixmapId, __GLXpixmap *pGlxPixmap) -{ - __GLPixBufferInfo *bufferInfo; - - buf->width = buf->height = 0; /* to be filled during Update */ - buf->depth = bits; - buf->size = 0; - buf->base = NULL; - buf->byteWidth = 0; - buf->elementSize = ((bits-1) / 8) + 1; - buf->elementSizeLog2 = __glFloorLog2(buf->elementSize); - - buf->handle = (void *)(long) glxpixmapId; - pGlxPixmap->refcnt++; - - buf->resize = Resize; - buf->lock = Lock; - buf->unlock = Unlock; - buf->fill = NULL; - buf->free = Free; - - /* allocate local information */ - bufferInfo = (__GLPixBufferInfo *) __glXMalloc(sizeof(__GLPixBufferInfo)); - buf->other = (void *) bufferInfo; - - bufferInfo->pGC = CreateScratchGC(pGlxPixmap->pDraw->pScreen, - pGlxPixmap->pDraw->depth); -} diff --git a/GL/glx/glxpix.h b/GL/glx/glxpix.h deleted file mode 100644 index 4b16352b4..000000000 --- a/GL/glx/glxpix.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $XFree86$ */ -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#ifndef _glxpix_h_ -#define _glxpix_h_ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -extern void __glXInitPix(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, - GLint bits, XID glxpixmapId, __GLXpixmap *pGlxPixmap); - -#endif /* _glxpix_h_ */ - diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c index ffe1935e3..aa727a981 100644 --- a/GL/glx/glxscreens.c +++ b/GL/glx/glxscreens.c @@ -38,12 +38,9 @@ #include <dix-config.h> #endif -#ifndef IN_MODULE #include <string.h> -#include <signal.h> -#endif - #include <windowstr.h> +#include <os.h> #include "glxserver.h" #include "glxutil.h" @@ -130,6 +127,7 @@ static char GLXServerExtensions[] = "GLX_EXT_visual_info " "GLX_EXT_visual_rating " "GLX_EXT_import_context " + "GLX_EXT_texture_from_pixmap " "GLX_OML_swap_method " "GLX_SGI_make_current_read " #ifndef __DARWIN__ @@ -140,75 +138,17 @@ static char GLXServerExtensions[] = "GLX_SGIX_fbconfig " ; -/* - * __glDDXScreenInfo comes from GLcore, so we can't resolve this symbol at - * module open time. Leave a placeholder, and fill this in when we first - * need it (in __glXScreenInit). XXX Why make this an array? - */ -static __GLXscreenInfo *__glXScreens[] = { - NULL /* &__glDDXScreenInfo */ , -}; - -static GLint __glXNumStaticScreens = - (sizeof __glXScreens / sizeof __glXScreens[0]); - -__GLXscreenInfo *__glXActiveScreens; -GLint __glXNumActiveScreens; +__GLXscreen **__glXActiveScreens; __GLXSwapBarrierExtensionFuncs *__glXSwapBarrierFuncs = NULL; static int __glXNumSwapBarrierFuncs = 0; __GLXHyperpipeExtensionFuncs *__glXHyperpipeFuncs = NULL; static int __glXNumHyperpipeFuncs = 0; - -RESTYPE __glXDrawableRes; - -__GLXscreenInfo *__glXgetActiveScreen(int num) { - return &__glXActiveScreens[num]; +__GLXscreen *__glXgetActiveScreen(int num) { + return __glXActiveScreens[num]; } -/* -** Destroy routine that gets called when a drawable is freed. A drawable -** contains the ancillary buffers needed for rendering. -*/ -static Bool DrawableGone(__GLXdrawablePrivate *glxPriv, XID xid) -{ - __GLXcontext *cx, *cx1; - - /* - ** Use glxPriv->type to figure out what kind of drawable this is. Don't - ** use glxPriv->pDraw->type because by the time this routine is called, - ** the pDraw might already have been freed. - */ - if (glxPriv->type == DRAWABLE_WINDOW) { - /* - ** When a window is destroyed, notify all context bound to - ** it, that there are no longer bound to anything. - */ - for (cx = glxPriv->drawGlxc; cx; cx = cx1) { - cx1 = cx->nextDrawPriv; - cx->pendingState |= __GLX_PENDING_DESTROY; - } - - for (cx = glxPriv->readGlxc; cx; cx = cx1) { - cx1 = cx->nextReadPriv; - cx->pendingState |= __GLX_PENDING_DESTROY; - } - } - - /* - ** set the size to 0, so that context that may still be using this - ** drawable not do anything harmful - */ - glxPriv->xorigin = 0; - glxPriv->yorigin = 0; - glxPriv->width = 0; - glxPriv->height = 0; - - __glXUnrefDrawablePrivate(glxPriv); - - return True; -} /* ** This hook gets called when a window moves or changes size. @@ -217,7 +157,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y) { ScreenPtr pScreen; __GLXcontext *glxc; - __GLXdrawablePrivate *glxPriv; + __GLXdrawable *glxPriv; Bool ret; /* @@ -225,7 +165,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y) */ pScreen = pWin->drawable.pScreen; pScreen->PositionWindow = - __glXActiveScreens[pScreen->myNum].WrappedPositionWindow; + __glXActiveScreens[pScreen->myNum]->WrappedPositionWindow; ret = (*pScreen->PositionWindow)(pWin, x, y); pScreen->PositionWindow = PositionWindow; @@ -233,8 +173,8 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y) ** Tell all contexts rendering into this window that the window size ** has changed. */ - glxPriv = (__GLXdrawablePrivate *) LookupIDByType(pWin->drawable.id, - __glXDrawableRes); + glxPriv = (__GLXdrawable *) LookupIDByType(pWin->drawable.id, + __glXDrawableRes); if (glxPriv == NULL) { /* ** This window is not being used by the OpenGL. @@ -246,7 +186,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y) ** resize the drawable */ /* first change the drawable size */ - if (__glXResizeDrawableBuffers(glxPriv) == GL_FALSE) { + if (glxPriv->resize(glxPriv) == GL_FALSE) { /* resize failed! */ /* XXX: what can we possibly do here? */ ret = False; @@ -266,18 +206,6 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y) } /* -** Wrap our own PositionWindow routine around the server's, so we can -** be notified when a window changes size -*/ -static void wrapPositionWindow(int screen) -{ - ScreenPtr pScreen = screenInfo.screens[screen]; - - __glXActiveScreens[screen].WrappedPositionWindow = pScreen->PositionWindow; - pScreen->PositionWindow = PositionWindow; -} - -/* * If your DDX driver wants to register support for swap barriers or hyperpipe * topology, it should call __glXHyperpipeInit() or __glXSwapBarrierInit() * with a dispatch table of functions to handle the requests. In the XFree86 @@ -320,57 +248,80 @@ void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs) funcs->queryMaxSwapBarriersFunc; } -void __glXScreenInit(GLint numscreens) +static __GLXprovider *__glXProviderStack; + +void GlxPushProvider(__GLXprovider *provider) +{ + provider->next = __glXProviderStack; + __glXProviderStack = provider; +} + +void __glXScreenInit(__GLXscreen *screen, ScreenPtr pScreen) +{ + screen->pScreen = pScreen; + screen->GLextensions = __glXStrdup(GLServerExtensions); + screen->GLXvendor = __glXStrdup(GLXServerVendorName); + screen->GLXversion = __glXStrdup(GLXServerVersion); + screen->GLXextensions = __glXStrdup(GLXServerExtensions); + + screen->WrappedPositionWindow = pScreen->PositionWindow; + pScreen->PositionWindow = PositionWindow; + + __glXScreenInitVisuals(screen); +} + +void +__glXScreenDestroy(__GLXscreen *screen) { - GLint i,j; + __glXFree(screen->GLXvendor); + __glXFree(screen->GLXversion); + __glXFree(screen->GLXextensions); + __glXFree(screen->GLextensions); +} - __glXScreens[0] = __glXglDDXScreenInfo(); /* from GLcore */ +void __glXInitScreens(void) +{ + GLint i; + ScreenPtr pScreen; + __GLXprovider *p; + size_t size; /* ** This alloc has to work or else the server might as well core dump. */ - __glXActiveScreens = - (__GLXscreenInfo *) __glXMalloc(sizeof(__GLXscreenInfo) * numscreens); + size = screenInfo.numScreens * sizeof(__GLXscreen *); + __glXActiveScreens =__glXMalloc(size); + __glXMemset(__glXActiveScreens, 0, size); - for (i=0; i < numscreens; i++) { - /* - ** Probe each static screen to see which exists. - */ - for (j=0; j < __glXNumStaticScreens; j++) { - if ((*__glXScreens[j]->screenProbe)(i)) { - __glXActiveScreens[i] = *__glXScreens[j]; - - __glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals; - __glXActiveScreens[i].GLextensions = __glXStrdup(GLServerExtensions); - __glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName); - __glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion); - __glXActiveScreens[i].GLXextensions = __glXStrdup(GLXServerExtensions); - - __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone); - wrapPositionWindow(i); + for (i = 0; i < screenInfo.numScreens; i++) { + pScreen = screenInfo.screens[i]; + + for (p = __glXProviderStack; p != NULL; p = p->next) { + __glXActiveScreens[i] = p->screenProbe(pScreen); + if (__glXActiveScreens[i] != NULL) { + LogMessage(X_INFO, + "GLX: Initialized %s GL provider for screen %d\n", + p->name, i); + break; } } } - __glXNumActiveScreens = numscreens; } -void __glXScreenReset(void) +void __glXResetScreens(void) { int i; - for (i = 0; i < __glXNumActiveScreens; i++) { - __glXFree(__glXActiveScreens[i].GLXvendor); - __glXFree(__glXActiveScreens[i].GLXversion); - __glXFree(__glXActiveScreens[i].GLXextensions); - __glXFree(__glXActiveScreens[i].GLextensions); - } - xfree(__glXActiveScreens); - xfree(__glXHyperpipeFuncs); - xfree(__glXSwapBarrierFuncs); - __glXNumHyperpipeFuncs = 0; - __glXNumSwapBarrierFuncs = 0; - __glXHyperpipeFuncs = NULL; - __glXSwapBarrierFuncs = NULL; - __glXActiveScreens = NULL; - __glXNumActiveScreens = 0; + for (i = 0; i < screenInfo.numScreens; i++) + if (__glXActiveScreens[i]) + __glXActiveScreens[i]->destroy(__glXActiveScreens[i]); + + __glXFree(__glXActiveScreens); + __glXFree(__glXHyperpipeFuncs); + __glXFree(__glXSwapBarrierFuncs); + __glXNumHyperpipeFuncs = 0; + __glXNumSwapBarrierFuncs = 0; + __glXHyperpipeFuncs = NULL; + __glXSwapBarrierFuncs = NULL; + __glXActiveScreens = NULL; } diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h index 2d68c8b60..8a2b2388f 100644 --- a/GL/glx/glxscreens.h +++ b/GL/glx/glxscreens.h @@ -51,28 +51,15 @@ ** and DDX layers of the GLX server extension. The methods provide an ** interface for context management on a screen. */ -typedef struct { - /* - ** Probe the screen and see if it supports GL rendering. It will - ** return GL_FALSE if it doesn't, GL_TRUE otherwise. - */ - Bool (*screenProbe)(int screen); +typedef struct __GLXscreen __GLXscreen; +struct __GLXscreen { + void (*destroy)(__GLXscreen *screen); - /* - ** Create a context using configuration information from modes. - ** Use imports as callbacks back to the OS. Return an opaque handle - ** on the context (NULL if failure). - */ - __GLinterface *(*createContext)(__GLimports *imports, - __GLcontextModes *modes, - __GLinterface *shareGC); + __GLXcontext *(*createContext)(__GLXscreen *screen, + __GLcontextModes *modes, + __GLXcontext *shareContext); - /* - ** Create a buffer using information from glxPriv. This routine - ** sets up any wrappers necessary to resize, swap or destroy the - ** buffer. - */ - void (*createBuffer)(__GLXdrawablePrivate *glxPriv); + ScreenPtr pScreen; /** * Linked list of valid context modes for this screen. @@ -94,10 +81,13 @@ typedef struct { */ Bool (*WrappedPositionWindow)(WindowPtr pWin, int x, int y); -} __GLXscreenInfo; +}; + +void __glXScreenInit(__GLXscreen *screen, ScreenPtr pScreen); +void __glXScreenDestroy(__GLXscreen *screen); -extern void __glXScreenInit(GLint); -extern void __glXScreenReset(void); +void __glXInitScreens(void); +extern void __glXResetScreens(void); #endif /* !__GLX_screens_h__ */ diff --git a/GL/glx/glxserver.h b/GL/glx/glxserver.h index 2609b1674..2e273b970 100644 --- a/GL/glx/glxserver.h +++ b/GL/glx/glxserver.h @@ -53,7 +53,6 @@ #include <scrnintstr.h> #include "GL/glx_ansic.h" - /* ** The X header misc.h defines these math functions. */ @@ -66,7 +65,8 @@ #include <GL/glxint.h> /* For glxscreens.h */ -typedef struct __GLXdrawablePrivateRec __GLXdrawablePrivate; +typedef struct __GLXdrawable __GLXdrawable; +typedef struct __GLXcontext __GLXcontext; #include "glxscreens.h" #include "glxdrawable.h" @@ -91,15 +91,19 @@ typedef XID GLXContextID; typedef XID GLXPixmap; typedef XID GLXDrawable; -typedef struct __GLXcontextRec *GLXContext; typedef struct __GLXclientStateRec __GLXclientState; -extern __GLXscreenInfo *__glXActiveScreens; +extern __GLXscreen **__glXActiveScreens; extern GLint __glXNumActiveScreens; -extern __GLXscreenInfo *__glXgetActiveScreen(int num); +extern __GLXscreen *__glXgetActiveScreen(int num); /************************************************************************/ +void GlxSetVisualConfigs(int nconfigs, + __GLXvisualConfig *configs, void **privates); + +void __glXScreenInitVisuals(__GLXscreen *screen); + /* ** The last context used (from the server's persective) is cached. */ @@ -116,6 +120,20 @@ extern __GLXcontext *__glXForceCurrent(__GLXclientState*, GLXContextTag, int*); /************************************************************************/ +typedef struct __GLXprovider __GLXprovider; +struct __GLXprovider { + __GLXscreen *(*screenProbe)(ScreenPtr pScreen); + const char *name; + __GLXprovider *next; +}; + +void GlxPushProvider(__GLXprovider *provider); + +void __glXsetEnterLeaveServerFuncs(void (*enter)(void), + void (*leave)(void)); +void __glXenterServer(void); +void __glXleaveServer(void); + /* ** State kept per client. */ @@ -214,6 +232,8 @@ extern void __glXSwapQueryVersionReply(ClientPtr client, extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXTReply *reply, int *buf); +extern void __glXSwapGetDrawableAttributesReply(ClientPtr client, + xGLXGetDrawableAttributesReply *reply, CARD32 *buf); extern void glxSwapQueryExtensionsStringReply(ClientPtr client, xGLXQueryExtensionsStringReply *reply, char *buf); extern void glxSwapQueryServerStringReply(ClientPtr client, diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c index 25586433f..8937d12aa 100644 --- a/GL/glx/glxutil.c +++ b/GL/glx/glxutil.c @@ -48,7 +48,6 @@ #include <pixmapstr.h> #include <windowstr.h> #include "glxutil.h" -#include "glxbuf.h" #include "GL/glx_ansic.h" #include "GL/internal/glcore.h" #include "GL/glxint.h" @@ -56,10 +55,6 @@ /************************************************************************/ -void __glXNop(void) {} - -/************************************************************************/ - /* Memory Allocation for GLX */ void * @@ -93,7 +88,7 @@ __glXCalloc(size_t numElements, size_t elementSize) /* XXX: handle out of memory error */ return NULL; } - __glXMemset(addr, 0, size); + memset(addr, 0, size); return addr; } @@ -144,13 +139,13 @@ __glXAssociateContext(__GLXcontext *glxc) glxc->nextDrawPriv = glxc->drawPriv->drawGlxc; glxc->drawPriv->drawGlxc = glxc; - __glXRefDrawablePrivate(glxc->drawPriv); + __glXRefDrawable(glxc->drawPriv); glxc->nextReadPriv = glxc->readPriv->readGlxc; glxc->readPriv->readGlxc = glxc; - __glXRefDrawablePrivate(glxc->readPriv); + __glXRefDrawable(glxc->readPriv); } /* @@ -173,7 +168,7 @@ __glXDeassociateContext(__GLXcontext *glxc) prev->nextDrawPriv = curr->nextDrawPriv; } curr->nextDrawPriv = NULL; - __glXUnrefDrawablePrivate(glxc->drawPriv); + __glXUnrefDrawable(glxc->drawPriv); break; } } @@ -191,319 +186,72 @@ __glXDeassociateContext(__GLXcontext *glxc) prev->nextReadPriv = curr->nextReadPriv; } curr->nextReadPriv = NULL; - __glXUnrefDrawablePrivate(glxc->readPriv); + __glXUnrefDrawable(glxc->readPriv); break; } } } -/************************************************************************/ - -void -__glXGetDrawableSize(__GLdrawablePrivate *glPriv, - GLint *x, GLint *y, GLuint *width, GLuint *height) -{ - __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other; - - if (glxPriv) { - *x = glxPriv->xorigin; - *y = glxPriv->yorigin; - *width = glxPriv->width; - *height = glxPriv->height; - } else { - *x = *y = *width = *height = 0; - } -} - -GLboolean -__glXResizeDrawable(__GLdrawablePrivate *glPriv) -{ - /* nothing to be done here */ - return GL_TRUE; -} - - -/*****************************************************************************/ -/* accessing the drawable private */ - -static void -LockDP(__GLdrawablePrivate *glPriv, __GLcontext *gc) -{ - __GLinterface *glci = (__GLinterface *) gc; - __GLXcontext *glxc = (__GLXcontext *) glci->imports.other; - - /* quick exit test */ - if ((glxc->pendingState & - (__GLX_PENDING_RESIZE | - __GLX_PENDING_DESTROY | - __GLX_PENDING_SWAP)) == 0x0) - return; - - /* some pending state. Deal with it */ - if (glxc->pendingState & __GLX_PENDING_RESIZE) { - glxc->pendingState &= ~__GLX_PENDING_RESIZE; - - (*glci->exports.notifyResize)(gc); - assert((glxc->pendingState & __GLX_PENDING_RESIZE) == 0x0); - } - if (glxc->pendingState & __GLX_PENDING_DESTROY) { - glxc->pendingState &= ~__GLX_PENDING_DESTROY; - - assert(glxc->drawPriv->xorigin == 0); - assert(glxc->drawPriv->yorigin == 0); - assert(glxc->drawPriv->width == 0); - assert(glxc->drawPriv->height == 0); - assert(glxc->readPriv->xorigin == 0); - assert(glxc->readPriv->yorigin == 0); - assert(glxc->readPriv->width == 0); - assert(glxc->readPriv->height == 0); - (*glci->exports.notifyDestroy)(gc); - __glXDeassociateContext(glxc); - assert((glxc->pendingState & __GLX_PENDING_DESTROY) == 0x0); - } - if (glxc->pendingState & __GLX_PENDING_SWAP) { - - glxc->pendingState &= ~__GLX_PENDING_SWAP; - - (*glci->exports.notifySwapBuffers)(gc); - assert((glxc->pendingState & __GLX_PENDING_SWAP) == 0x0); - } -} - -static void -UnlockDP(__GLdrawablePrivate *glPriv) -{ -} - /*****************************************************************************/ /* Drawable private stuff */ void -__glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv) +__glXRefDrawable(__GLXdrawable *glxPriv) { glxPriv->refCount++; } void -__glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv) +__glXUnrefDrawable(__GLXdrawable *glxPriv) { glxPriv->refCount--; if (glxPriv->refCount == 0) { - __glXDestroyDrawablePrivate(glxPriv); + /* remove the drawable from the drawable list */ + FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE); + glxPriv->destroy(glxPriv); } } -__GLXdrawablePrivate * -__glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId, - __GLcontextModes *modes) +GLboolean +__glXDrawableInit(__GLXdrawable *drawable, + __GLXcontext *ctx, DrawablePtr pDraw, XID drawId) { - __GLXdrawablePrivate *glxPriv; - __GLdrawablePrivate *glPriv; - __GLXscreenInfo *pGlxScreen; - - glxPriv = (__GLXdrawablePrivate *) __glXMalloc(sizeof(*glxPriv)); - __glXMemset(glxPriv, 0, sizeof(__GLXdrawablePrivate)); - - glxPriv->type = pDraw->type; - glxPriv->pDraw = pDraw; - glxPriv->drawId = drawId; + drawable->type = pDraw->type; + drawable->pDraw = pDraw; + drawable->drawId = drawId; + drawable->refCount = 1; /* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */ - glxPriv->pGlxPixmap = (__GLXpixmap *) + drawable->pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId, __glXPixmapRes); - /* since we are creating the drawablePrivate, drawId should be new */ - if (!AddResource(drawId, __glXDrawableRes, glxPriv)) { - /* oops! */ - __glXFree(glxPriv); - return NULL; - } - - /* fill up glPriv */ - glPriv = &glxPriv->glPriv; - glPriv->modes = (__GLcontextModes *) __glXMalloc(sizeof(__GLcontextModes)); - *glPriv->modes = *modes; - glPriv->malloc = __glXMalloc; - glPriv->calloc = __glXCalloc; - glPriv->realloc = __glXRealloc; - glPriv->free = __glXFree; - glPriv->addSwapRect = NULL; - glPriv->setClipRect = (void (*)(__GLdrawablePrivate *, GLint, GLint, GLsizei, GLsizei)) __glXNop; - glPriv->lockDP = LockDP; - glPriv->unlockDP = UnlockDP; - glPriv->getDrawableSize = __glXGetDrawableSize; - glPriv->resize = __glXResizeDrawable; - glPriv->other = glxPriv; - - /* allocate a one-rect ownership region */ - glPriv->ownershipRegion.rects = - (__GLregionRect *)__glXCalloc(1, sizeof(__GLregionRect)); - glPriv->ownershipRegion.numRects = 1; - - glxPriv->freeBuffers = __glXFreeBuffers; - glxPriv->updatePalette = (void (*)(__GLXdrawablePrivate *)) __glXNop; - - pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum]; - - if (glxPriv->type == DRAWABLE_WINDOW) { - VisualID vid = wVisual((WindowPtr)pDraw); - - glxPriv->modes = _gl_context_modes_find_visual( pGlxScreen->modes, vid ); - __glXFBInitDrawable(glxPriv, modes); - } else { - glxPriv->modes = glxPriv->pGlxPixmap->modes; - __glXPixInitDrawable(glxPriv, modes); - } - - /* initialize the core's private buffer information */ - (*pGlxScreen->createBuffer)(glxPriv); - - return glxPriv; -} -GLboolean -__glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv) -{ - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; - - /* remove the drawable from the drawable list */ - FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE); - - /* Have the core free any memory it may have attached to the drawable */ - if (glPriv->freePrivate) { - (*glPriv->freePrivate)(glPriv); - } - - /* Free any framebuffer memory attached to the drawable */ - if (glxPriv->freeBuffers) { - (*glxPriv->freeBuffers)(glxPriv); + /* since we are creating the drawablePrivate, drawId should be new */ + if (!AddResource(drawId, __glXDrawableRes, drawable)) { + return GL_FALSE; } - /* Free the drawable Private */ - __glXFree(glxPriv->glPriv.modes); - __glXFree(glxPriv->glPriv.ownershipRegion.rects); - __glXFree(glxPriv); - return GL_TRUE; } -__GLXdrawablePrivate * -__glXFindDrawablePrivate(XID drawId) +__GLXdrawable * +__glXFindDrawable(XID drawId) { - __GLXdrawablePrivate *glxPriv; + __GLXdrawable *glxPriv; - glxPriv = (__GLXdrawablePrivate *)LookupIDByType(drawId, __glXDrawableRes); + glxPriv = (__GLXdrawable *)LookupIDByType(drawId, __glXDrawableRes); return glxPriv; } -__GLXdrawablePrivate * -__glXGetDrawablePrivate(DrawablePtr pDraw, XID drawId, - __GLcontextModes *modes) +__GLXdrawable * +__glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId) { - __GLXdrawablePrivate *glxPriv; + __GLXdrawable *glxPriv; - glxPriv = __glXFindDrawablePrivate(drawId); + glxPriv = __glXFindDrawable(drawId); - if (glxPriv == NULL) { - glxPriv = __glXCreateDrawablePrivate(pDraw, drawId, modes); - if (glxPriv) { - __glXRefDrawablePrivate(glxPriv); - } - } + if (glxPriv == NULL) + glxPriv = ctx->createDrawable(ctx, pDraw, drawId); return glxPriv; } - -void -__glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv) -{ - if (glxPriv) { - if (glxPriv->pDraw) { - glxPriv->xorigin = glxPriv->pDraw->x; - glxPriv->yorigin = glxPriv->pDraw->y; - glxPriv->width = glxPriv->pDraw->width; - glxPriv->height = glxPriv->pDraw->height; - } - } -} - -/* -** resize/move the drawable. Called during the actual resize callback -** to update the drawable side of the buffers -*/ -GLboolean -__glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv) -{ - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; - GLint x, y; - GLuint w, h; -#if defined(__GL_ALIGNED_BUFFERS) - GLint xAlignment, yAlignment; - GLint xOffset, yOffset; - GLint xStart, xEnd; - GLint yStart, yEnd; - GLuint xAlignedMask, yAlignedMask; -#endif - GLboolean status = GL_TRUE; - - __glXCacheDrawableSize(glxPriv); - - w = glxPriv->width; - h = glxPriv->height; - x = glxPriv->xorigin; - y = glxPriv->yorigin; - -#if defined(__GL_ALIGNED_BUFFERS) - xAlignment = glPriv->xAlignment; - yAlignment = glPriv->yAlignment; - - xOffset = x & (xAlignment-1); - yOffset = y & (yAlignment-1); - - xAlignedMask = ~(xAlignment-1); - yAlignedMask = ~(yAlignment-1); - - xStart = x; xEnd = x+w; - yStart = y; yEnd = y+h; - - xStart &= xAlignedMask; - if (xEnd & ~xAlignedMask) { - xEnd = (xEnd&xAlignedMask) + xAlignment; - } - yStart &= yAlignedMask; - if (yEnd & ~yAlignedMask) { - yEnd = (yEnd&yAlignedMask) + yAlignment; - } - - x = xStart; y = yStart; - w = xEnd-xStart; h = yEnd-yStart; -#endif - - if ((x != glPriv->xOrigin) || - (y != glPriv->yOrigin) || -#if defined(__GL_ALIGNED_BUFFERS) - (xOffset != glPriv->xOffset) || - (yOffset != glPriv->yOffset) || -#endif - (w != glPriv->width) || - (h != glPriv->height) || - (!w && !h)) { - /* set up the glPriv info */ - glPriv->width = w; - glPriv->height = h; - glPriv->xOrigin = x; - glPriv->yOrigin = y; -#if defined(__GL_ALIGNED_BUFFERS) - glPriv->xOffset = xOffset; - glPriv->yOffset = yOffset; -#endif - - /* notify the buffers */ - status = __glXResizeBuffers(glPriv, x, y, w, h); - } - - return status; -} - -/************************************************************************/ - diff --git a/GL/glx/glxutil.h b/GL/glx/glxutil.h index 2c3090a46..07384bf76 100644 --- a/GL/glx/glxutil.h +++ b/GL/glx/glxutil.h @@ -58,20 +58,23 @@ extern void __glXGetDrawableSize(__GLdrawablePrivate *glPriv, GLint *x, GLint *y, GLuint *width, GLuint *height); extern GLboolean __glXResizeDrawable(__GLdrawablePrivate *glPriv); -extern GLboolean __glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv); +extern GLboolean __glXResizeDrawableBuffers(__GLXdrawable *glxPriv); /* drawable management */ -extern void __glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv); -extern void __glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv); -extern __GLXdrawablePrivate *__glXCreateDrawablePrivate(DrawablePtr pDraw, - XID glxpixmapId, - __GLcontextModes *modes); -extern GLboolean __glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv); -extern __GLXdrawablePrivate *__glXFindDrawablePrivate(XID glxpixmapId); -extern __GLXdrawablePrivate *__glXGetDrawablePrivate(DrawablePtr pDraw, - XID glxpixmapId, - __GLcontextModes *modes); -extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv); +extern void __glXRefDrawable(__GLXdrawable *glxPriv); +extern void __glXUnrefDrawable(__GLXdrawable *glxPriv); + +extern __GLXdrawable *__glXCreateDrawable(__GLXcontext *ctx, + DrawablePtr pDraw, + XID glxpixmapId); +extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, __GLXcontext *ctx, + DrawablePtr pDraw, XID drawID); +extern GLboolean __glXDestroyDrawable(__GLXdrawable *glxPriv); +extern __GLXdrawable *__glXFindDrawable(XID glxpixmapId); +extern __GLXdrawable *__glXGetDrawable(__GLXcontext *ctx, + DrawablePtr pDraw, + XID glxpixmapId); +extern void __glXCacheDrawableSize(__GLXdrawable *glxPriv); /* context helper routines */ extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag); diff --git a/GL/glx/glxvisuals.c b/GL/glx/glxvisuals.c new file mode 100644 index 000000000..9b5839ce9 --- /dev/null +++ b/GL/glx/glxvisuals.c @@ -0,0 +1,517 @@ +/* + * Copyright © 2006 Red Hat, Inc. + * (C) Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * 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 + * 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 + * RED HAT, INC, OR PRECISION INSIGHT 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. + */ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * Brian Paul <brian@precisioninsight.com> + * Kristian Høgsberg <krh@redhat.com> + * + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <string.h> +#include <regionstr.h> +#include <resource.h> +#include <GL/gl.h> +#include <GL/glxint.h> +#include <GL/glxtokens.h> +#include <GL/internal/glcore.h> +#include <scrnintstr.h> +#include <config.h> +#include <glxserver.h> +#include <glxscreens.h> +#include <glxdrawable.h> +#include <glxcontext.h> +#include <glxext.h> +#include <glxutil.h> +#include <micmap.h> + +void GlxWrapInitVisuals(miInitVisualsProcPtr *); + +#include "glcontextmodes.h" + +struct ScreenVisualsRec { + int num_vis; + void *private; + __GLcontextModes *modes; +}; +typedef struct ScreenVisualsRec ScreenVisuals; + +static ScreenVisuals screenVisuals[MAXSCREENS]; + +static int numConfigs = 0; +static __GLXvisualConfig *visualConfigs = NULL; +static void **visualPrivates = NULL; + +static int count_bits(unsigned int n) +{ + int bits = 0; + + while (n > 0) { + if (n & 1) bits++; + n >>= 1; + } + return bits; +} + +/* + * In the case the driver defines no GLX visuals we'll use these. + * Note that for TrueColor and DirectColor visuals, bufferSize is the + * sum of redSize, greenSize, blueSize and alphaSize, which may be larger + * than the nplanes/rootDepth of the server's X11 visuals + */ +#define NUM_FALLBACK_CONFIGS 5 +static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { + /* [0] = RGB, double buffered, Z */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [1] = RGB, double buffered, Z, stencil, accum */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 16, 16, 16, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 8, /* rgba sizes */ + -1, -1, -1, -1, /* rgba masks */ + 16, 16, 16, 16, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */ + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 8, /* rgba sizes */ + -1, -1, -1, -1, /* rgba masks */ + 16, 16, 16, 16, /* rgba accum sizes */ + False, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + /* [4] = CI, double buffered, Z */ + { + -1, /* vid */ + -1, /* class */ + False, /* rgba? (false = color index) */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE, /* visualRating */ + GLX_NONE, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, +}; + + +static Bool init_visuals(int *nvisualp, VisualPtr *visualp, + VisualID *defaultVisp, + int ndepth, DepthPtr pdepth, + int rootDepth) +{ + int numRGBconfigs; + int numCIconfigs; + int numVisuals = *nvisualp; + int numNewVisuals; + int numNewConfigs; + VisualPtr pVisual = *visualp; + VisualPtr pVisualNew = NULL; + VisualID *orig_vid = NULL; + __GLcontextModes *modes; + __GLXvisualConfig *pNewVisualConfigs = NULL; + void **glXVisualPriv; + void **pNewVisualPriv; + int found_default; + int i, j, k; + + if (numConfigs > 0) + numNewConfigs = numConfigs; + else + numNewConfigs = NUM_FALLBACK_CONFIGS; + + /* Alloc space for the list of new GLX visuals */ + pNewVisualConfigs = (__GLXvisualConfig *) + __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig)); + if (!pNewVisualConfigs) { + return FALSE; + } + + /* Alloc space for the list of new GLX visual privates */ + pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *)); + if (!pNewVisualPriv) { + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* + ** If SetVisualConfigs was not called, then use default GLX + ** visual configs. + */ + if (numConfigs == 0) { + memcpy(pNewVisualConfigs, FallbackConfigs, + NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig)); + memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); + } + else { + /* copy driver's visual config info */ + for (i = 0; i < numConfigs; i++) { + pNewVisualConfigs[i] = visualConfigs[i]; + pNewVisualPriv[i] = visualPrivates[i]; + } + } + + /* Count the number of RGB and CI visual configs */ + numRGBconfigs = 0; + numCIconfigs = 0; + for (i = 0; i < numNewConfigs; i++) { + if (pNewVisualConfigs[i].rgba) + numRGBconfigs++; + else + numCIconfigs++; + } + + /* Count the total number of visuals to compute */ + numNewVisuals = 0; + for (i = 0; i < numVisuals; i++) { + numNewVisuals += + (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor) + ? numRGBconfigs : numCIconfigs; + } + + /* Reset variables for use with the next screen/driver's visual configs */ + visualConfigs = NULL; + numConfigs = 0; + + /* Alloc temp space for the list of orig VisualIDs for each new visual */ + orig_vid = (VisualID *) __glXMalloc(numNewVisuals * sizeof(VisualID)); + if (!orig_vid) { + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Alloc space for the list of glXVisuals */ + modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); + if (modes == NULL) { + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Alloc space for the list of glXVisualPrivates */ + glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); + if (!glXVisualPriv) { + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Alloc space for the new list of the X server's visuals */ + pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); + if (!pVisualNew) { + __glXFree(glXVisualPriv); + _gl_context_modes_destroy( modes ); + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + return FALSE; + } + + /* Initialize the new visuals */ + found_default = FALSE; + screenVisuals[screenInfo.numScreens-1].modes = modes; + for (i = j = 0; i < numVisuals; i++) { + int is_rgb = (pVisual[i].class == TrueColor || + pVisual[i].class == DirectColor); + + for (k = 0; k < numNewConfigs; k++) { + if (pNewVisualConfigs[k].rgba != is_rgb) + continue; + + assert( modes != NULL ); + + /* Initialize the new visual */ + pVisualNew[j] = pVisual[i]; + pVisualNew[j].vid = FakeClientID(0); + + /* Check for the default visual */ + if (!found_default && pVisual[i].vid == *defaultVisp) { + *defaultVisp = pVisualNew[j].vid; + found_default = TRUE; + } + + /* Save the old VisualID */ + orig_vid[j] = pVisual[i].vid; + + /* Initialize the glXVisual */ + _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] ); + modes->visualID = pVisualNew[j].vid; + if (modes->fbconfigID == GLX_DONT_CARE) + modes->fbconfigID = modes->visualID; + + /* + * If the class is -1, then assume the X visual information + * is identical to what GLX needs, and take them from the X + * visual. NOTE: if class != -1, then all other fields MUST + * be initialized. + */ + if (modes->visualType == GLX_NONE) { + modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class ); + modes->redBits = count_bits(pVisual[i].redMask); + modes->greenBits = count_bits(pVisual[i].greenMask); + modes->blueBits = count_bits(pVisual[i].blueMask); + modes->alphaBits = modes->alphaBits; + modes->redMask = pVisual[i].redMask; + modes->greenMask = pVisual[i].greenMask; + modes->blueMask = pVisual[i].blueMask; + modes->alphaMask = modes->alphaMask; + modes->rgbBits = (is_rgb) + ? (modes->redBits + modes->greenBits + + modes->blueBits + modes->alphaBits) + : rootDepth; + } + + /* Save the device-dependent private for this visual */ + glXVisualPriv[j] = pNewVisualPriv[k]; + + j++; + modes = modes->next; + } + } + + assert(j <= numNewVisuals); + + /* Save the GLX visuals in the screen structure */ + screenVisuals[screenInfo.numScreens-1].num_vis = numNewVisuals; + screenVisuals[screenInfo.numScreens-1].private = glXVisualPriv; + + /* Set up depth's VisualIDs */ + for (i = 0; i < ndepth; i++) { + int numVids = 0; + VisualID *pVids = NULL; + int k, n = 0; + + /* Count the new number of VisualIDs at this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + numVids++; + + /* Allocate a new list of VisualIDs for this depth */ + pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); + + /* Initialize the new list of VisualIDs for this depth */ + for (j = 0; j < pdepth[i].numVids; j++) + for (k = 0; k < numNewVisuals; k++) + if (pdepth[i].vids[j] == orig_vid[k]) + pVids[n++] = pVisualNew[k].vid; + + /* Update this depth's list of VisualIDs */ + __glXFree(pdepth[i].vids); + pdepth[i].vids = pVids; + pdepth[i].numVids = numVids; + } + + /* Update the X server's visuals */ + *nvisualp = numNewVisuals; + *visualp = pVisualNew; + + /* Free the old list of the X server's visuals */ + __glXFree(pVisual); + + /* Clean up temporary allocations */ + __glXFree(orig_vid); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); + + /* Free the private list created by DDX HW driver */ + if (visualPrivates) + __glXFree(visualPrivates); + visualPrivates = NULL; + + return TRUE; +} + +void GlxSetVisualConfigs(int nconfigs, + __GLXvisualConfig *configs, void **privates) +{ + numConfigs = nconfigs; + visualConfigs = configs; + visualPrivates = privates; +} + +static miInitVisualsProcPtr saveInitVisualsProc; + +static Bool __glXInitVisuals(VisualPtr *visualp, DepthPtr *depthp, + int *nvisualp, int *ndepthp, + int *rootDepthp, VisualID *defaultVisp, + unsigned long sizes, int bitsPerRGB, + int preferredVis) +{ + Bool ret; + + if (saveInitVisualsProc) { + ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp, + rootDepthp, defaultVisp, sizes, bitsPerRGB, + preferredVis); + if (!ret) + return False; + } + + /* + * Setup the visuals supported by this particular screen. + */ + init_visuals(nvisualp, visualp, defaultVisp, + *ndepthp, *depthp, *rootDepthp); + + + return True; +} + + +/************************************************************************/ + + +void +GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc) +{ + saveInitVisualsProc = *initVisProc; + *initVisProc = __glXInitVisuals; +} + +static void fixup_visuals(int screen) +{ + ScreenPtr pScreen = screenInfo.screens[screen]; + ScreenVisuals *psv = &screenVisuals[screen]; + int j; + __GLcontextModes *modes; + + for ( modes = psv->modes ; modes != NULL ; modes = modes->next ) { + const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); + const int nplanes = (modes->rgbBits - modes->alphaBits); + const VisualPtr pVis = pScreen->visuals; + + /* Find a visual that matches the GLX visual's class and size */ + for (j = 0; j < pScreen->numVisuals; j++) { + if (pVis[j].class == vis_class && + pVis[j].nplanes == nplanes) { + + /* Fixup the masks */ + modes->redMask = pVis[j].redMask; + modes->greenMask = pVis[j].greenMask; + modes->blueMask = pVis[j].blueMask; + + /* Recalc the sizes */ + modes->redBits = count_bits(modes->redMask); + modes->greenBits = count_bits(modes->greenMask); + modes->blueBits = count_bits(modes->blueMask); + } + } + } +} + +void __glXScreenInitVisuals(__GLXscreen *screen) +{ + int index = screen->pScreen->myNum; + + screen->modes = screenVisuals[index].modes; + screen->pVisualPriv = screenVisuals[index].private; + screen->numVisuals = screenVisuals[index].num_vis; + screen->numUsableVisuals = screenVisuals[index].num_vis; + + /* + * The ordering of the rgb compenents might have been changed by the + * driver after mi initialized them. + */ + fixup_visuals(index); +} diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c index 5dd4e7c37..b185a958a 100644 --- a/GL/mesa/X/xf86glx.c +++ b/GL/mesa/X/xf86glx.c @@ -37,12 +37,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <dix-config.h> #endif +#include <string.h> #include <regionstr.h> #include <resource.h> #include <GL/gl.h> #include <GL/glxint.h> #include <GL/glxtokens.h> #include <scrnintstr.h> +#include <windowstr.h> #include <config.h> #include <glxserver.h> #include <glxscreens.h> @@ -50,12 +52,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <glxcontext.h> #include <glxext.h> #include <glxutil.h> -#include "xf86glxint.h" #include "context.h" #include "xmesaP.h" #include <GL/xf86glx.h> #include "context.h" +#include "glcontextmodes.h" +#include "os.h" + /* * This define is for the glcore.h header file. * If you add it here, then make sure you also add it in @@ -69,489 +73,265 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <GL/internal/glcore.h> #endif -#include "glcontextmodes.h" +typedef struct __GLXMESAscreen __GLXMESAscreen; +typedef struct __GLXMESAcontext __GLXMESAcontext; +typedef struct __GLXMESAdrawable __GLXMESAdrawable; -/* - * This structure is statically allocated in the __glXScreens[] - * structure. This struct is not used anywhere other than in - * __glXScreenInit to initialize each of the active screens - * (__glXActiveScreens[]). Several of the fields must be initialized by - * the screenProbe routine before they are copied to the active screens - * struct. In particular, the contextCreate, pGlxVisual, numVisuals, - * and numUsableVisuals fields must be initialized. - */ -static __GLXscreenInfo __glDDXScreenInfo = { - __MESA_screenProbe, /* Must be generic and handle all screens */ - __MESA_createContext, /* Substitute screen's createContext routine */ - __MESA_createBuffer, /* Substitute screen's createBuffer routine */ - NULL, /* Set up modes in probe */ - NULL, /* Set up pVisualPriv in probe */ - 0, /* Set up numVisuals in probe */ - 0, /* Set up numUsableVisuals in probe */ - NULL, /* GLextensions is overwritten by __glXScreenInit */ - "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */ - "Version String", /* GLXversion is overwritten by __glXScreenInit */ - "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */ - NULL /* WrappedPositionWindow is overwritten */ +struct __GLXMESAscreen { + __GLXscreen base; + int index; + XMesaVisual *xm_vis; }; -void *__glXglDDXScreenInfo(void) { - return &__glDDXScreenInfo; -} +struct __GLXMESAcontext { + __GLXcontext base; + XMesaContext xmesa; +}; -static __GLXextensionInfo __glDDXExtensionInfo = { - GL_CORE_MESA, - __MESA_resetExtension, - __MESA_initVisuals, - __MESA_setVisualConfigs +struct __GLXMESAdrawable { + __GLXdrawable base; + XMesaBuffer xm_buf; }; -void *__glXglDDXExtensionInfo(void) { - return &__glDDXExtensionInfo; -} +static XMesaVisual find_mesa_visual(__GLXscreen *screen, VisualID vid); -static __MESA_screen MESAScreens[MAXSCREENS]; -static __GLcontext *MESA_CC = NULL; -static int numConfigs = 0; -static __GLXvisualConfig *visualConfigs = NULL; -static void **visualPrivates = NULL; +static void +__glXMesaDrawableDestroy(__GLXdrawable *base) +{ + __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base; + XMesaDestroyBuffer(glxPriv->xm_buf); + xfree(glxPriv); +} -static int count_bits(unsigned int n) +static GLboolean +__glXMesaDrawableResize(__GLXdrawable *base) { - int bits = 0; + __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base; - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} + XMesaResizeBuffers(glxPriv->xm_buf); + return GL_TRUE; +} -static XMesaVisual find_mesa_visual(int screen, VisualID vid) +static GLboolean +__glXMesaDrawableSwapBuffers(__GLXdrawable *base) { - __MESA_screen * const pMScr = &MESAScreens[screen]; - const __GLcontextModes *modes; - unsigned i = 0; + __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base; - for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) { - if ( modes->visualID == vid ) { - break; - } + /* This is terrifying: XMesaSwapBuffers() ends up calling CopyArea + * to do the buffer swap, but this assumes that the server holds + * the lock and has its context visible. If another screen uses a + * DRI driver, that will have installed the DRI enter/leave server + * functions, which lifts the lock during GLX dispatch. This is + * why we need to re-take the lock and swap in the server context + * before calling XMesaSwapBuffers() here. /me shakes head. */ - i++; - } + __glXenterServer(); - return (modes != NULL) ? pMScr->xm_vis[i] : NULL; -} + XMesaSwapBuffers(glxPriv->xm_buf); + __glXleaveServer(); -/* - * In the case the driver defines no GLX visuals we'll use these. - * Note that for TrueColor and DirectColor visuals, bufferSize is the - * sum of redSize, greenSize, blueSize and alphaSize, which may be larger - * than the nplanes/rootDepth of the server's X11 visuals - */ -#define NUM_FALLBACK_CONFIGS 5 -static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { - /* [0] = RGB, double buffered, Z */ - { - -1, /* vid */ - -1, /* class */ - True, /* rgba */ - -1, -1, -1, 0, /* rgba sizes */ - -1, -1, -1, 0, /* rgba masks */ - 0, 0, 0, 0, /* rgba accum sizes */ - True, /* doubleBuffer */ - False, /* stereo */ - -1, /* bufferSize */ - 16, /* depthSize */ - 0, /* stencilSize */ - 0, /* auxBuffers */ - 0, /* level */ - GLX_NONE, /* visualRating */ - GLX_NONE, /* transparentPixel */ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ - 0 /* transparentIndex */ - }, - /* [1] = RGB, double buffered, Z, stencil, accum */ - { - -1, /* vid */ - -1, /* class */ - True, /* rgba */ - -1, -1, -1, 0, /* rgba sizes */ - -1, -1, -1, 0, /* rgba masks */ - 16, 16, 16, 0, /* rgba accum sizes */ - True, /* doubleBuffer */ - False, /* stereo */ - -1, /* bufferSize */ - 16, /* depthSize */ - 8, /* stencilSize */ - 0, /* auxBuffers */ - 0, /* level */ - GLX_NONE, /* visualRating */ - GLX_NONE, /* transparentPixel */ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ - 0 /* transparentIndex */ - }, - /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */ - { - -1, /* vid */ - -1, /* class */ - True, /* rgba */ - -1, -1, -1, 8, /* rgba sizes */ - -1, -1, -1, -1, /* rgba masks */ - 16, 16, 16, 16, /* rgba accum sizes */ - True, /* doubleBuffer */ - False, /* stereo */ - -1, /* bufferSize */ - 16, /* depthSize */ - 8, /* stencilSize */ - 0, /* auxBuffers */ - 0, /* level */ - GLX_NONE, /* visualRating */ - GLX_NONE, /* transparentPixel */ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ - 0 /* transparentIndex */ - }, - /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */ - { - -1, /* vid */ - -1, /* class */ - True, /* rgba */ - -1, -1, -1, 8, /* rgba sizes */ - -1, -1, -1, -1, /* rgba masks */ - 16, 16, 16, 16, /* rgba accum sizes */ - False, /* doubleBuffer */ - False, /* stereo */ - -1, /* bufferSize */ - 16, /* depthSize */ - 8, /* stencilSize */ - 0, /* auxBuffers */ - 0, /* level */ - GLX_NONE, /* visualRating */ - GLX_NONE, /* transparentPixel */ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ - 0 /* transparentIndex */ - }, - /* [4] = CI, double buffered, Z */ - { - -1, /* vid */ - -1, /* class */ - False, /* rgba? (false = color index) */ - -1, -1, -1, 0, /* rgba sizes */ - -1, -1, -1, 0, /* rgba masks */ - 0, 0, 0, 0, /* rgba accum sizes */ - True, /* doubleBuffer */ - False, /* stereo */ - -1, /* bufferSize */ - 16, /* depthSize */ - 0, /* stencilSize */ - 0, /* auxBuffers */ - 0, /* level */ - GLX_NONE, /* visualRating */ - GLX_NONE, /* transparentPixel */ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ - 0 /* transparentIndex */ - }, -}; + return GL_TRUE; +} -static Bool init_visuals(int *nvisualp, VisualPtr *visualp, - VisualID *defaultVisp, - int ndepth, DepthPtr pdepth, - int rootDepth) +static __GLXdrawable * +__glXMesaContextCreateDrawable(__GLXcontext *context, + DrawablePtr pDraw, + XID drawId) { - int numRGBconfigs; - int numCIconfigs; - int numVisuals = *nvisualp; - int numNewVisuals; - int numNewConfigs; - VisualPtr pVisual = *visualp; - VisualPtr pVisualNew = NULL; - VisualID *orig_vid = NULL; - __GLcontextModes *modes; - __GLXvisualConfig *pNewVisualConfigs = NULL; - void **glXVisualPriv; - void **pNewVisualPriv; - int found_default; - int i, j, k; - - if (numConfigs > 0) - numNewConfigs = numConfigs; - else - numNewConfigs = NUM_FALLBACK_CONFIGS; - - /* Alloc space for the list of new GLX visuals */ - pNewVisualConfigs = (__GLXvisualConfig *) - __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig)); - if (!pNewVisualConfigs) { - return FALSE; - } + __GLXMESAdrawable *glxPriv; + __GLXscreen *pGlxScreen; + XMesaVisual xm_vis; - /* Alloc space for the list of new GLX visual privates */ - pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *)); - if (!pNewVisualPriv) { - __glXFree(pNewVisualConfigs); - return FALSE; - } + glxPriv = xalloc(sizeof *glxPriv); + if (glxPriv == NULL) + return NULL; - /* - ** If SetVisualConfigs was not called, then use default GLX - ** visual configs. - */ - if (numConfigs == 0) { - memcpy(pNewVisualConfigs, FallbackConfigs, - NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig)); - memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); - } - else { - /* copy driver's visual config info */ - for (i = 0; i < numConfigs; i++) { - pNewVisualConfigs[i] = visualConfigs[i]; - pNewVisualPriv[i] = visualPrivates[i]; - } - } + memset(glxPriv, 0, sizeof *glxPriv); - /* Count the number of RGB and CI visual configs */ - numRGBconfigs = 0; - numCIconfigs = 0; - for (i = 0; i < numNewConfigs; i++) { - if (pNewVisualConfigs[i].rgba) - numRGBconfigs++; - else - numCIconfigs++; + if (!__glXDrawableInit(&glxPriv->base, context, pDraw, drawId)) { + xfree(glxPriv); + return NULL; } - /* Count the total number of visuals to compute */ - numNewVisuals = 0; - for (i = 0; i < numVisuals; i++) { - numNewVisuals += - (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor) - ? numRGBconfigs : numCIconfigs; - } + glxPriv->base.destroy = __glXMesaDrawableDestroy; + glxPriv->base.resize = __glXMesaDrawableResize; + glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers; - /* Reset variables for use with the next screen/driver's visual configs */ - visualConfigs = NULL; - numConfigs = 0; + pGlxScreen = __glXActiveScreens[pDraw->pScreen->myNum]; - /* Alloc temp space for the list of orig VisualIDs for each new visual */ - orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID)); - if (!orig_vid) { - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; - } + if (glxPriv->base.type == DRAWABLE_WINDOW) { + VisualID vid = wVisual((WindowPtr)pDraw); - /* Alloc space for the list of glXVisuals */ - modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes)); - if (modes == NULL) { - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + glxPriv->base.modes = _gl_context_modes_find_visual(pGlxScreen->modes, + vid); + } else { + glxPriv->base.modes = glxPriv->base.pGlxPixmap->modes; } - /* Alloc space for the list of glXVisualPrivates */ - glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); - if (!glXVisualPriv) { - _gl_context_modes_destroy( modes ); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + xm_vis = find_mesa_visual(pGlxScreen, glxPriv->base.modes->visualID); + if (xm_vis == NULL) { + ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n", + glxPriv->base.modes->visualID); + xfree(glxPriv); + return NULL; } - /* Alloc space for the new list of the X server's visuals */ - pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); - if (!pVisualNew) { - __glXFree(glXVisualPriv); - _gl_context_modes_destroy( modes ); - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); - return FALSE; + if (glxPriv->base.type == DRAWABLE_WINDOW) { + glxPriv->xm_buf = XMesaCreateWindowBuffer(xm_vis, (WindowPtr)pDraw); + } else { + glxPriv->xm_buf = XMesaCreatePixmapBuffer(xm_vis, (PixmapPtr)pDraw, 0); } - /* Initialize the new visuals */ - found_default = FALSE; - MESAScreens[screenInfo.numScreens-1].modes = modes; - for (i = j = 0; i < numVisuals; i++) { - int is_rgb = (pVisual[i].class == TrueColor || - pVisual[i].class == DirectColor); - - for (k = 0; k < numNewConfigs; k++) { - if (pNewVisualConfigs[k].rgba != is_rgb) - continue; - - assert( modes != NULL ); + return &glxPriv->base; +} - /* Initialize the new visual */ - pVisualNew[j] = pVisual[i]; - pVisualNew[j].vid = FakeClientID(0); +static void +__glXMesaContextDestroy(__GLXcontext *baseContext) +{ + __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext; - /* Check for the default visual */ - if (!found_default && pVisual[i].vid == *defaultVisp) { - *defaultVisp = pVisualNew[j].vid; - found_default = TRUE; - } + XMesaDestroyContext(context->xmesa); + xfree(context); +} - /* Save the old VisualID */ - orig_vid[j] = pVisual[i].vid; - - /* Initialize the glXVisual */ - _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] ); - modes->visualID = pVisualNew[j].vid; - - /* - * If the class is -1, then assume the X visual information - * is identical to what GLX needs, and take them from the X - * visual. NOTE: if class != -1, then all other fields MUST - * be initialized. - */ - if (modes->visualType == GLX_NONE) { - modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class ); - modes->redBits = count_bits(pVisual[i].redMask); - modes->greenBits = count_bits(pVisual[i].greenMask); - modes->blueBits = count_bits(pVisual[i].blueMask); - modes->alphaBits = modes->alphaBits; - modes->redMask = pVisual[i].redMask; - modes->greenMask = pVisual[i].greenMask; - modes->blueMask = pVisual[i].blueMask; - modes->alphaMask = modes->alphaMask; - modes->rgbBits = (is_rgb) - ? (modes->redBits + modes->greenBits + - modes->blueBits + modes->alphaBits) - : rootDepth; - } +static int +__glXMesaContextMakeCurrent(__GLXcontext *baseContext) - /* Save the device-dependent private for this visual */ - glXVisualPriv[j] = pNewVisualPriv[k]; +{ + __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext; + __GLXMESAdrawable *drawPriv = (__GLXMESAdrawable *) context->base.drawPriv; + __GLXMESAdrawable *readPriv = (__GLXMESAdrawable *) context->base.readPriv; - j++; - modes = modes->next; - } - } + return XMesaMakeCurrent2(context->xmesa, + drawPriv->xm_buf, + readPriv->xm_buf); +} - assert(j <= numNewVisuals); - - /* Save the GLX visuals in the screen structure */ - MESAScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; - MESAScreens[screenInfo.numScreens-1].private = glXVisualPriv; - - /* Set up depth's VisualIDs */ - for (i = 0; i < ndepth; i++) { - int numVids = 0; - VisualID *pVids = NULL; - int k, n = 0; - - /* Count the new number of VisualIDs at this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numNewVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - numVids++; - - /* Allocate a new list of VisualIDs for this depth */ - pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID)); - - /* Initialize the new list of VisualIDs for this depth */ - for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numNewVisuals; k++) - if (pdepth[i].vids[j] == orig_vid[k]) - pVids[n++] = pVisualNew[k].vid; - - /* Update this depth's list of VisualIDs */ - __glXFree(pdepth[i].vids); - pdepth[i].vids = pVids; - pdepth[i].numVids = numVids; - } +static int +__glXMesaContextLoseCurrent(__GLXcontext *baseContext) +{ + __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext; - /* Update the X server's visuals */ - *nvisualp = numNewVisuals; - *visualp = pVisualNew; + return XMesaLoseCurrent(context->xmesa); +} - /* Free the old list of the X server's visuals */ - __glXFree(pVisual); +static int +__glXMesaContextCopy(__GLXcontext *baseDst, + __GLXcontext *baseSrc, + unsigned long mask) +{ + __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst; + __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc; - /* Clean up temporary allocations */ - __glXFree(orig_vid); - __glXFree(pNewVisualPriv); - __glXFree(pNewVisualConfigs); + _mesa_copy_context(&src->xmesa->mesa, &dst->xmesa->mesa, mask); + return GL_TRUE; +} - /* Free the private list created by DDX HW driver */ - if (visualPrivates) - xfree(visualPrivates); - visualPrivates = NULL; +static int +__glXMesaContextForceCurrent(__GLXcontext *baseContext) +{ + __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext; - return TRUE; + return XMesaForceCurrent(context->xmesa); } -void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **privates) +static __GLXcontext * +__glXMesaScreenCreateContext(__GLXscreen *screen, + __GLcontextModes *modes, + __GLXcontext *baseShareContext) { - numConfigs = nconfigs; - visualConfigs = configs; - visualPrivates = privates; + __GLXMESAcontext *context; + __GLXMESAcontext *shareContext = (__GLXMESAcontext *) baseShareContext; + XMesaVisual xm_vis; + XMesaContext xm_share; + + context = xalloc (sizeof (__GLXMESAcontext)); + if (context == NULL) + return NULL; + + memset(context, 0, sizeof *context); + + context->base.pGlxScreen = screen; + context->base.modes = modes; + + context->base.destroy = __glXMesaContextDestroy; + context->base.makeCurrent = __glXMesaContextMakeCurrent; + context->base.loseCurrent = __glXMesaContextLoseCurrent; + context->base.copy = __glXMesaContextCopy; + context->base.forceCurrent = __glXMesaContextForceCurrent; + context->base.createDrawable = __glXMesaContextCreateDrawable; + + xm_vis = find_mesa_visual(screen, modes->visualID); + if (!xm_vis) { + ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n", + modes->visualID); + xfree(context); + return NULL; + } + + xm_share = shareContext ? shareContext->xmesa : NULL; + context->xmesa = XMesaCreateContext(xm_vis, xm_share); + if (!context->xmesa) { + xfree(context); + return NULL; + } + + return &context->base; } -Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, int *rootDepthp, - VisualID *defaultVisp, unsigned long sizes, - int bitsPerRGB) +static void +__glXMesaScreenDestroy(__GLXscreen *screen) { - /* - * Setup the visuals supported by this particular screen. - */ - return init_visuals(nvisualp, visualp, defaultVisp, - *ndepthp, *depthp, *rootDepthp); + __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen; + int i; + + for (i = 0; i < screen->numVisuals; i++) { + if (mesaScreen->xm_vis[i]) + XMesaDestroyVisual(mesaScreen->xm_vis[i]); + } + + xfree(mesaScreen->xm_vis); + + __glXScreenDestroy(screen); + + xfree(screen); } -static void fixup_visuals(int screen) +static XMesaVisual +find_mesa_visual(__GLXscreen *screen, VisualID vid) { - ScreenPtr pScreen = screenInfo.screens[screen]; - __MESA_screen *pMScr = &MESAScreens[screen]; - int j; - __GLcontextModes *modes; - - for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) { - const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); - const int nplanes = (modes->rgbBits - modes->alphaBits); - const VisualPtr pVis = pScreen->visuals; + __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen; + const __GLcontextModes *modes; + unsigned i = 0; - /* Find a visual that matches the GLX visual's class and size */ - for (j = 0; j < pScreen->numVisuals; j++) { - if (pVis[j].class == vis_class && - pVis[j].nplanes == nplanes) { - - /* Fixup the masks */ - modes->redMask = pVis[j].redMask; - modes->greenMask = pVis[j].greenMask; - modes->blueMask = pVis[j].blueMask; - - /* Recalc the sizes */ - modes->redBits = count_bits(modes->redMask); - modes->greenBits = count_bits(modes->greenMask); - modes->blueBits = count_bits(modes->blueMask); - } + for ( modes = screen->modes ; modes != NULL ; modes = modes->next ) { + if ( modes->visualID == vid ) { + break; } + + i++; } + + return (modes != NULL) ? mesaScreen->xm_vis[i] : NULL; } -static void init_screen_visuals(int screen) +static void init_screen_visuals(__GLXMESAscreen *screen) { - ScreenPtr pScreen = screenInfo.screens[screen]; + ScreenPtr pScreen = screen->base.pScreen; __GLcontextModes *modes; XMesaVisual *pXMesaVisual; int *used; - int i, j; + int i, j, size; /* Alloc space for the list of XMesa visuals */ - pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis * - sizeof(XMesaVisual)); - __glXMemset(pXMesaVisual, 0, - MESAScreens[screen].num_vis * sizeof(XMesaVisual)); + size = screen->base.numVisuals * sizeof(XMesaVisual); + pXMesaVisual = (XMesaVisual *) xalloc(size); + memset(pXMesaVisual, 0, size); /* FIXME: Change 'used' to be a array of bits (rather than of ints), * FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less @@ -559,13 +339,11 @@ static void init_screen_visuals(int screen) * FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to * FIXME: array of bytes instead of ints! */ - used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int)); - __glXMemset(used, 0, pScreen->numVisuals * sizeof(int)); + used = (int *) xalloc(pScreen->numVisuals * sizeof(int)); + memset(used, 0, pScreen->numVisuals * sizeof(int)); i = 0; - for ( modes = MESAScreens[screen].modes - ; modes != NULL - ; modes = modes->next ) { + for ( modes = screen->base.modes; modes != NULL; modes = modes->next ) { const int vis_class = _gl_convert_to_x_visual_type( modes->visualType ); const int nplanes = (modes->rgbBits - modes->alphaBits); const VisualPtr pVis = pScreen->visuals; @@ -621,30 +399,23 @@ static void init_screen_visuals(int screen) __glXFree(used); - MESAScreens[screen].xm_vis = pXMesaVisual; + screen->xm_vis = pXMesaVisual; } -Bool __MESA_screenProbe(int screen) +static __GLXscreen * +__glXMesaScreenProbe(ScreenPtr pScreen) { - /* - * Set up the current screen's visuals. - */ - __glDDXScreenInfo.modes = MESAScreens[screen].modes; - __glDDXScreenInfo.pVisualPriv = MESAScreens[screen].private; - __glDDXScreenInfo.numVisuals = - __glDDXScreenInfo.numUsableVisuals = MESAScreens[screen].num_vis; + __GLXMESAscreen *screen; - /* - * Set the current screen's createContext routine. This could be - * wrapped by a DDX GLX context creation routine. - */ - __glDDXScreenInfo.createContext = __MESA_createContext; + screen = xalloc(sizeof *screen); + if (screen == NULL) + return NULL; - /* - * The ordering of the rgb compenents might have been changed by the - * driver after mi initialized them. - */ - fixup_visuals(screen); + __glXScreenInit(&screen->base, pScreen); + + screen->base.destroy = __glXMesaScreenDestroy; + screen->base.createContext = __glXMesaScreenCreateContext; + screen->base.pScreen = pScreen; /* * Find the GLX visuals that are supported by this screen and create @@ -652,263 +423,11 @@ Bool __MESA_screenProbe(int screen) */ init_screen_visuals(screen); - return TRUE; -} - -extern void __MESA_resetExtension(void) -{ - int i, j; - - XMesaReset(); - - for (i = 0; i < screenInfo.numScreens; i++) { - for (j = 0; j < MESAScreens[i].num_vis; j++) { - if (MESAScreens[i].xm_vis[j]) { - XMesaDestroyVisual(MESAScreens[i].xm_vis[j]); - MESAScreens[i].xm_vis[j] = NULL; - } - } - _gl_context_modes_destroy( MESAScreens[i].modes ); - MESAScreens[i].modes = NULL; - __glXFree(MESAScreens[i].private); - MESAScreens[i].private = NULL; - __glXFree(MESAScreens[i].xm_vis); - MESAScreens[i].xm_vis = NULL; - MESAScreens[i].num_vis = 0; - } - __glDDXScreenInfo.modes = NULL; - MESA_CC = NULL; -} - -void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv) -{ - DrawablePtr pDraw = glxPriv->pDraw; - XMesaVisual xm_vis = find_mesa_visual(pDraw->pScreen->myNum, - glxPriv->modes->visualID); - __GLdrawablePrivate *glPriv = &glxPriv->glPriv; - __MESA_buffer buf; - - if (xm_vis == NULL) { - ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n", - glxPriv->modes->visualID); - } - buf = (__MESA_buffer)__glXMalloc(sizeof(struct __MESA_bufferRec)); - - /* Create Mesa's buffers */ - if (glxPriv->type == DRAWABLE_WINDOW) { - buf->xm_buf = (void *)XMesaCreateWindowBuffer(xm_vis, - (WindowPtr)pDraw); - } else { - buf->xm_buf = (void *)XMesaCreatePixmapBuffer(xm_vis, - (PixmapPtr)pDraw, 0); - } - - /* Wrap the front buffer's resize routine */ - buf->fbresize = glPriv->frontBuffer.resize; - glPriv->frontBuffer.resize = __MESA_resizeBuffers; - - /* Wrap the swap buffers routine */ - buf->fbswap = glxPriv->swapBuffers; - glxPriv->swapBuffers = __MESA_swapBuffers; - - /* Save Mesa's private buffer structure */ - glPriv->private = (void *)buf; - glPriv->freePrivate = __MESA_destroyBuffer; -} - -GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buffer, - GLint x, GLint y, - GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, - GLuint bufferMask) -{ - __MESA_buffer buf = (__MESA_buffer)glPriv->private; - - if (buf->xm_buf) - XMesaResizeBuffers(buf->xm_buf); - - return (*buf->fbresize)(buffer, x, y, width, height, glPriv, bufferMask); -} - -GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv) -{ - __MESA_buffer buf = (__MESA_buffer)glxPriv->glPriv.private; - - /* - ** Do not call the wrapped swap buffers routine since Mesa has - ** already done the swap. - */ - XMesaSwapBuffers(buf->xm_buf); - - return GL_TRUE; -} - -void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv) -{ - __MESA_buffer buf = (__MESA_buffer)glPriv->private; - __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other; - - /* Destroy Mesa's buffers */ - if (buf->xm_buf) - XMesaDestroyBuffer(buf->xm_buf); - - /* Unwrap these routines */ - glxPriv->swapBuffers = buf->fbswap; - glPriv->frontBuffer.resize = buf->fbresize; - - __glXFree(glPriv->private); - glPriv->private = NULL; -} - -__GLinterface *__MESA_createContext(__GLimports *imports, - __GLcontextModes *modes, - __GLinterface *shareGC) -{ - __GLcontext *gl_ctx = NULL; - __GLcontext *m_share = NULL; - __GLXcontext *glxc = (__GLXcontext *)imports->other; - XMesaVisual xm_vis; - - if (shareGC) - m_share = (__GLcontext *)shareGC; - - xm_vis = find_mesa_visual(glxc->pScreen->myNum, glxc->modes->visualID); - if (xm_vis) { - XMesaContext xmshare = m_share ? m_share->DriverCtx : 0; - XMesaContext xmctx = XMesaCreateContext(xm_vis, xmshare); - gl_ctx = xmctx ? &xmctx->mesa : 0; - } - else { - ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n", - glxc->modes->visualID); - } - - - if (!gl_ctx) - return NULL; - - gl_ctx->imports = *imports; - gl_ctx->exports.destroyContext = __MESA_destroyContext; - gl_ctx->exports.loseCurrent = __MESA_loseCurrent; - gl_ctx->exports.makeCurrent = __MESA_makeCurrent; - gl_ctx->exports.shareContext = __MESA_shareContext; - gl_ctx->exports.copyContext = __MESA_copyContext; - gl_ctx->exports.forceCurrent = __MESA_forceCurrent; - gl_ctx->exports.notifyResize = __MESA_notifyResize; - gl_ctx->exports.notifyDestroy = __MESA_notifyDestroy; - gl_ctx->exports.notifySwapBuffers = __MESA_notifySwapBuffers; - gl_ctx->exports.dispatchExec = __MESA_dispatchExec; - gl_ctx->exports.beginDispatchOverride = __MESA_beginDispatchOverride; - gl_ctx->exports.endDispatchOverride = __MESA_endDispatchOverride; - - return (__GLinterface *)gl_ctx; -} - -GLboolean __MESA_destroyContext(__GLcontext *gc) -{ - XMesaContext xmesa = (XMesaContext) gc->DriverCtx; - XMesaDestroyContext( xmesa ); - return GL_TRUE; -} - -GLboolean __MESA_loseCurrent(__GLcontext *gc) -{ - XMesaContext xmesa = (XMesaContext) gc->DriverCtx; - MESA_CC = NULL; - __glXLastContext = NULL; - return XMesaLoseCurrent(xmesa); -} - -GLboolean __MESA_makeCurrent(__GLcontext *gc) -{ - __GLdrawablePrivate *drawPriv = gc->imports.getDrawablePrivate( gc ); - __MESA_buffer drawBuf = (__MESA_buffer)drawPriv->private; - __GLdrawablePrivate *readPriv = gc->imports.getReadablePrivate( gc ); - __MESA_buffer readBuf = (__MESA_buffer)readPriv->private; - XMesaContext xmesa = (XMesaContext) gc->DriverCtx; - - MESA_CC = gc; - return XMesaMakeCurrent2(xmesa, drawBuf->xm_buf, readBuf->xm_buf); -} - -GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare) -{ - /* NOT_DONE */ - /* XXX I don't see where/how this could ever be called */ - ErrorF("__MESA_shareContext\n"); - return GL_FALSE; -} - -GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src, - GLuint mask) -{ - XMesaContext xm_dst = (XMesaContext) dst->DriverCtx; - const XMesaContext xm_src = (const XMesaContext) src->DriverCtx; - _mesa_copy_context(&xm_src->mesa, &xm_dst->mesa, mask); - return GL_TRUE; -} - -GLboolean __MESA_forceCurrent(__GLcontext *gc) -{ - XMesaContext xmesa = (XMesaContext) gc->DriverCtx; - MESA_CC = gc; - return XMesaForceCurrent(xmesa); -} - -GLboolean __MESA_notifyResize(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_notifyResize\n"); - return GL_FALSE; -} - -void __MESA_notifyDestroy(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_notifyDestroy\n"); - return; -} - -void __MESA_notifySwapBuffers(__GLcontext *gc) -{ - _mesa_notifySwapBuffers(gc); -} - -struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_dispatchExec\n"); - return NULL; -} - -void __MESA_beginDispatchOverride(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_beginDispatchOverride\n"); - return; -} - -void __MESA_endDispatchOverride(__GLcontext *gc) -{ - /* NOT_DONE */ - ErrorF("__MESA_endDispatchOverride\n"); - return; -} - - -/* - * Server-side GLX uses these functions which are normally defined - * in the OpenGL SI. - */ - -GLuint __glFloorLog2(GLuint val) -{ - int c = 0; - - while (val > 1) { - c++; - val >>= 1; - } - return c; + return &screen->base; } +__GLXprovider __glXMesaProvider = { + __glXMesaScreenProbe, + "MESA", + NULL +}; diff --git a/GL/mesa/X/xf86glxint.h b/GL/mesa/X/xf86glxint.h index 974ff0364..4e51215bc 100644 --- a/GL/mesa/X/xf86glxint.h +++ b/GL/mesa/X/xf86glxint.h @@ -43,60 +43,4 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <GL/gl.h> #include <GL/xmesa.h> -typedef struct __MESA_screenRec __MESA_screen; -struct __MESA_screenRec { - int num_vis; - __GLcontextModes *modes; - XMesaVisual *xm_vis; - void **private; -}; - -typedef struct __MESA_bufferRec *__MESA_buffer; -struct __MESA_bufferRec { - XMesaBuffer xm_buf; - GLboolean (*fbresize)(__GLdrawableBuffer *buf, - GLint x, GLint y, GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, GLuint bufferMask); - GLboolean (*fbswap)(__GLXdrawablePrivate *glxPriv); -}; - -extern void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs, - void **privates); -extern Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp, - int *nvisualp, int *ndepthp, int *rootDepthp, - VisualID *defaultVisp, unsigned long sizes, - int bitsPerRGB); -extern Bool __MESA_screenProbe(int screen); - -extern void __MESA_resetExtension(void); - -extern void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv); -extern GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buf, - GLint x, GLint y, - GLuint width, GLuint height, - __GLdrawablePrivate *glPriv, - GLuint bufferMask); -extern GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv); -extern void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv); - -extern __GLinterface *__MESA_createContext(__GLimports *imports, - __GLcontextModes *modes, - __GLinterface *shareGC); -extern GLboolean __MESA_destroyContext(__GLcontext *gc); -extern GLboolean __MESA_loseCurrent(__GLcontext *gc); -extern GLboolean __MESA_makeCurrent(__GLcontext *gc); -extern GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare); -extern GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src, - GLuint mask); -extern GLboolean __MESA_forceCurrent(__GLcontext *gc); - -extern GLboolean __MESA_notifyResize(__GLcontext *gc); -extern void __MESA_notifyDestroy(__GLcontext *gc); -extern void __MESA_notifySwapBuffers(__GLcontext *gc); -extern struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc); -extern void __MESA_beginDispatchOverride(__GLcontext *gc); -extern void __MESA_endDispatchOverride(__GLcontext *gc); - -extern GLuint __glFloorLog2(GLuint val); - #endif /* _XF86GLXINT_H_ */ diff --git a/GL/mesa/swrast/Makefile.am b/GL/mesa/swrast/Makefile.am index 5a0ed9cd3..973de3ac2 100644 --- a/GL/mesa/swrast/Makefile.am +++ b/GL/mesa/swrast/Makefile.am @@ -10,6 +10,7 @@ INCLUDES = -I@MESA_SOURCE@/include \ -I../math \ -I../shader \ -I../shader/slang \ + -I../shader/slang \ -I../swrast \ -I../swrast_setup \ -I../tnl \ diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh index fa14f629d..afd1f5501 100755 --- a/GL/symlink-mesa.sh +++ b/GL/symlink-mesa.sh @@ -63,6 +63,7 @@ symlink_mesa_glapi() { dst_dir mesa/glapi action dispatch.h + action glapi.c action glapi.h action glapioffsets.h action glapitable.h diff --git a/configure.ac b/configure.ac index a8971dbbe..1cedcfa55 100644 --- a/configure.ac +++ b/configure.ac @@ -362,6 +362,9 @@ AC_ARG_WITH(xkb-output, AS_HELP_STRING([--with-xkb-output=PATH], [Path to AC_ARG_WITH(rgb-path, AS_HELP_STRING([--with-rgb-path=PATH], [Path to RGB database (default: ${datadir}/X11/rgb)]), [ RGBPATH="$withval" ], [ RGBPATH="${datadir}/X11/rgb" ]) +AC_ARG_WITH(dri-driver-path, AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to DRI drivers (default: ${libdir}/dri)]), + [ DRI_DRIVER_PATH="$withval" ], + [ DRI_DRIVER_PATH="${libdir}/dri" ]) AC_ARG_ENABLE(builddocs, AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]), [BUILDDOCS=$enableval], [BUILDDOCS=no]) @@ -384,6 +387,7 @@ AC_ARG_ENABLE(screensaver, AS_HELP_STRING([--disable-screensaver], [Build Scr AC_ARG_ENABLE(xdmcp, AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto]) AC_ARG_ENABLE(xdm-auth-1, AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto]) AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes]) +AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]), [AIGLX=$enableval], [AIGLX=yes]) AC_ARG_ENABLE(dri, AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval]) AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes]) AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: enabled)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=yes]) @@ -559,6 +563,13 @@ fi AM_CONDITIONAL(GLX, test "x$GLX" = xyes) AC_SUBST([MESA_SOURCE]) +if test "x$AIGLX" = xyes -a "x$GLX" = xyes -a "x$DRI" = xyes; then + AC_DEFINE(AIGLX, 1, [Build AIGLX loader]) +else + AIGLX=no +fi +AM_CONDITIONAL(AIGLX, test "x$AIGLX" = xyes) + PKG_CHECK_MODULES([LBXUTIL_TEST], [lbxutil], [have_lbxutil=yes], [have_lbxutil=no]) if test "x$LBX" = xauto; then @@ -768,6 +779,7 @@ VENDOR_MAN_VERSION="Version ${VENDOR_VERSION_STRING}" AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path]) AC_DEFINE_DIR(RGB_DB, RGBPATH, [Default RGB path]) +AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path]) AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_STRING"], [Vendor name]) AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_STRING_SHORT"], [Short vendor name]) AC_DEFINE_UNQUOTED(XORG_RELEASE, ["$VENDOR_RELEASE_STRING"], [Vendor release]) diff --git a/hw/dmx/glxProxy/glxext.c b/hw/dmx/glxProxy/glxext.c index 60338230e..5ddfbe608 100644 --- a/hw/dmx/glxProxy/glxext.c +++ b/hw/dmx/glxProxy/glxext.c @@ -37,6 +37,13 @@ #include "glxswap.h" /* +** Stubs to satisfy miinitext.c references. +*/ +typedef int __GLXprovider; +__GLXprovider __glXMesaProvider; +void GlxPushProvider(__GLXprovider *provider) { } + +/* ** Forward declarations. */ static int __glXSwapDispatch(ClientPtr); diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index aded9132d..448f85594 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Config.c,v 1.21 2005/12/20 21:34:21 ajax Exp $ */ +/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Config.c,v 1.22.8.2 2006/02/28 23:55:03 krh Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.276 2003/10/08 14:58:26 dawes Exp $ */ @@ -756,7 +756,8 @@ typedef enum { FLAG_LOG, FLAG_RENDER_COLORMAP_MODE, FLAG_HANDLE_SPECIAL_KEYS, - FLAG_RANDR + FLAG_RANDR, + FLAG_AIGLX } FlagValues; static OptionInfoRec FlagOptions[] = { @@ -826,6 +827,8 @@ static OptionInfoRec FlagOptions[] = { {0}, FALSE }, { FLAG_RANDR, "RandR", OPTV_BOOLEAN, {0}, FALSE }, + { FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN, + {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE }, }; @@ -1010,6 +1013,13 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) else xf86Info.estimateSizesAggressively = 0; + xf86Info.aiglx = TRUE; + xf86Info.aiglxFrom = X_DEFAULT; + if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) { + xf86Info.aiglx = value; + xf86Info.aiglxFrom = X_CONFIG; + } + /* Make sure that timers don't overflow CARD32's after multiplying */ #define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN) diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index 84c3e32c3..ea6d25b09 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -196,11 +196,15 @@ extern ExtensionModule *ExtensionModuleList; pointer LoadSubModule(pointer, const char *, const char **, const char **, pointer, const XF86ModReqInfo *, int *, int *); +pointer LoadSubModuleLocal(pointer, const char *, const char **, + const char **, pointer, const XF86ModReqInfo *, + int *, int *); void UnloadSubModule(pointer); void LoadFont(pointer); void UnloadModule (pointer); #endif pointer LoaderSymbol(const char *); +pointer LoaderSymbolLocal(pointer module, const char *); char **LoaderListDirs(const char **, const char **); void LoaderFreeDirList(char **); void LoaderErrorMsg(const char *, const char *, int, int); diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h index 2f15e14cb..a35de2065 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h @@ -165,6 +165,8 @@ typedef struct { Bool kbdCustomKeycodes; Bool disableRandR; MessageType randRFrom; + Bool aiglx; + MessageType aiglxFrom; struct { Bool disabled; /* enable/disable deactivating * grabs or closing the diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am index 6b744d727..0e06f5464 100644 --- a/hw/xfree86/dixmods/Makefile.am +++ b/hw/xfree86/dixmods/Makefile.am @@ -36,7 +36,8 @@ INCLUDES = @XORG_INCS@ \ -I$(top_srcdir)/mfb \ -I$(top_srcdir)/dbe \ -I$(top_srcdir)/hw/xfree86/loader \ - -I$(top_srcdir)/miext/shadow + -I$(top_srcdir)/miext/shadow \ + -I$(top_srcdir)/GL/glx libGLcore_la_LDFLAGS = -avoid-version libGLcore_la_LIBADD = $(top_builddir)/GL/mesa/libGLcore.la @@ -72,7 +73,9 @@ libfb_la_LIBADD = $(top_builddir)/fb/libfb.la libfb_la_SOURCES = $(top_builddir)/fb/fbcmap.c fbmodule.c libglx_la_LDFLAGS = -avoid-version -libglx_la_LIBADD = $(top_builddir)/GL/glx/libglx.la +libglx_la_LIBADD = \ + $(top_builddir)/GL/glx/libglx.la \ + $(top_builddir)/GL/glx/libglxdri.la libglx_la_SOURCES = glxmodule.c libmfb_la_LDFLAGS = -avoid-version diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c index f8c03913e..9869b0295 100644 --- a/hw/xfree86/dixmods/glxmodule.c +++ b/hw/xfree86/dixmods/glxmodule.c @@ -37,15 +37,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif #include "xf86Module.h" +#include "xf86Priv.h" +#include "xf86.h" #include "colormap.h" #include "micmap.h" #include "globals.h" -static MODULESETUPPROTO(glxSetup); +typedef struct __GLXscreen __GLXscreen; +typedef struct __GLXprovider __GLXprovider; +struct __GLXprovider { + __GLXscreen *(*screenProbe)(ScreenPtr pScreen); + const char *name; + __GLXprovider *next; +}; -extern void GlxExtensionInit(INITARGS); +extern void GlxPushProvider(__GLXprovider *provider); +extern void GlxExtensionInit(void); extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); -extern void InitGlxWrapInitVisuals(void (*f)(miInitVisualsProcPtr *)); + +static MODULESETUPPROTO(glxSetup); static const char *initdeps[] = { "DOUBLE-BUFFER", NULL }; @@ -58,1168 +68,6 @@ ExtensionModule GLXExt = initdeps }; -static const char *glcoreSymbols[] = { - "__glCallLists_size", - "__glColorTableParameterfv_size", - "__glColorTableParameteriv_size", - "__glConvolutionParameterfv_size", - "__glConvolutionParameteriv_size", - "__glDDXExtensionInfo", - "__glDDXScreenInfo", - "__glFloorLog2", - "__glFogfv_size", - "__glFogiv_size", - "__glGetBooleanv_size", - "__glGetColorTableParameterfv_size", - "__glGetColorTableParameteriv_size", - "__glGetConvolutionParameterfv_size", - "__glGetConvolutionParameteriv_size", - "__glGetDoublev_size", - "__glGetFloatv_size", - "__glGetHistogramParameterfv_size", - "__glGetHistogramParameteriv_size", - "__glGetIntegerv_size", - "__glGetLightfv_size", - "__glGetLightiv_size", - "__glGetMapdv_size", - "__glGetMapfv_size", - "__glGetMapiv_size", - "__glGetMaterialfv_size", - "__glGetMaterialiv_size", - "__glGetMinmaxParameterfv_size", - "__glGetMinmaxParameteriv_size", - "__glGetPixelMapfv_size", - "__glGetPixelMapuiv_size", - "__glGetPixelMapusv_size", - "__glGetTexEnvfv_size", - "__glGetTexEnviv_size", - "__glGetTexGendv_size", - "__glGetTexGenfv_size", - "__glGetTexGeniv_size", - "__glGetTexImage_size", - "__glGetTexLevelParameterfv_size", - "__glGetTexLevelParameteriv_size", - "__glGetTexParameterfv_size", - "__glGetTexParameteriv_size", - "__glLightModelfv_size", - "__glLightModeliv_size", - "__glLightfv_size", - "__glLightiv_size", - "__glMaterialfv_size", - "__glMaterialiv_size", - "__glPointParameterfvARB_size", - "__glReadPixels_size", - "__glTexEnvfv_size", - "__glTexEnviv_size", - "__glTexGendv_size", - "__glTexGenfv_size", - "__glTexGeniv_size", - "__glTexParameterfv_size", - "__glTexParameteriv_size", - "__glXglDDXExtensionInfo", - "__glXglDDXScreenInfo", - "__glXActiveScreens", - "__glXAssociateContext", - "__glXBadContext", - "__glXBadContextState", - "__glXBadContextTag", - "__glXBadCurrentWindow", - "__glXBadDrawable", - "__glXBadLargeRequest", - "__glXBadPixmap", - "__glXBadRenderRequest", - "__glXBitmapReqSize", - "__glXCacheDrawableSize", - "__glXCallListsReqSize", - "__glXClearErrorOccured", - "__glXClientInfo", - "__glXClientRes", - "__glXClients", - "__glXColorSubTableReqSize", - "__glXColorTableParameterfvReqSize", - "__glXColorTableParameterivReqSize", - "__glXColorTableReqSize", - "__glXContextRes", - "__glXConvolutionFilter1DReqSize", - "__glXConvolutionFilter2DReqSize", - "__glXConvolutionParameterfvReqSize", - "__glXConvolutionParameterivReqSize", - "__glXCopyContext", - "__glXCoreType", - "__glXCreateContext", - "__glXCreateGLXPixmap", - "__glXDeassociateContext", - "__glXDestroyContext", - "__glXDestroyGLXPixmap", - "__glXDispSwap_Accum", - "__glXDispSwap_ActiveStencilFaceEXT", - "__glXDispSwap_ActiveTextureARB", - "__glXDispSwap_AlphaFunc", - "__glXDispSwap_AreTexturesResident", - "__glXDispSwap_AreTexturesResidentEXT", - "__glXDispSwap_Begin", - "__glXDispSwap_BindTexture", - "__glXDispSwap_Bitmap", - "__glXDispSwap_BlendColor", - "__glXDispSwap_BlendEquation", - "__glXDispSwap_BlendFunc", - "__glXDispSwap_CallList", - "__glXDispSwap_CallLists", - "__glXDispSwap_Clear", - "__glXDispSwap_ClearAccum", - "__glXDispSwap_ClearColor", - "__glXDispSwap_ClearDepth", - "__glXDispSwap_ClearIndex", - "__glXDispSwap_ClearStencil", - "__glXDispSwap_ClipPlane", - "__glXDispSwap_Color3bv", - "__glXDispSwap_Color3dv", - "__glXDispSwap_Color3fv", - "__glXDispSwap_Color3iv", - "__glXDispSwap_Color3sv", - "__glXDispSwap_Color3ubv", - "__glXDispSwap_Color3uiv", - "__glXDispSwap_Color3usv", - "__glXDispSwap_Color4bv", - "__glXDispSwap_Color4dv", - "__glXDispSwap_Color4fv", - "__glXDispSwap_Color4iv", - "__glXDispSwap_Color4sv", - "__glXDispSwap_Color4ubv", - "__glXDispSwap_Color4uiv", - "__glXDispSwap_Color4usv", - "__glXDispSwap_ColorMask", - "__glXDispSwap_ColorMaterial", - "__glXDispSwap_ColorSubTable", - "__glXDispSwap_ColorTable", - "__glXDispSwap_ColorTableParameterfv", - "__glXDispSwap_ColorTableParameteriv", - "__glXDispSwap_ConvolutionFilter1D", - "__glXDispSwap_ConvolutionFilter2D", - "__glXDispSwap_ConvolutionParameterf", - "__glXDispSwap_ConvolutionParameterfv", - "__glXDispSwap_ConvolutionParameteri", - "__glXDispSwap_ConvolutionParameteriv", - "__glXDispSwap_CopyColorSubTable", - "__glXDispSwap_CopyColorTable", - "__glXDispSwap_CopyConvolutionFilter1D", - "__glXDispSwap_CopyConvolutionFilter2D", - "__glXDispSwap_CopyPixels", - "__glXDispSwap_CopyTexImage1D", - "__glXDispSwap_CopyTexImage2D", - "__glXDispSwap_CopyTexSubImage1D", - "__glXDispSwap_CopyTexSubImage2D", - "__glXDispSwap_CopyTexSubImage3D", - "__glXDispSwap_CullFace", - "__glXDispSwap_DeleteLists", - "__glXDispSwap_DeleteTextures", - "__glXDispSwap_DeleteTexturesEXT", - "__glXDispSwap_DepthFunc", - "__glXDispSwap_DepthMask", - "__glXDispSwap_DepthRange", - "__glXDispSwap_Disable", - "__glXDispSwap_DrawArrays", - "__glXDispSwap_DrawArraysEXT", - "__glXDispSwap_DrawBuffer", - "__glXDispSwap_DrawPixels", - "__glXDispSwap_EdgeFlagv", - "__glXDispSwap_Enable", - "__glXDispSwap_End", - "__glXDispSwap_EndList", - "__glXDispSwap_EvalCoord1dv", - "__glXDispSwap_EvalCoord1fv", - "__glXDispSwap_EvalCoord2dv", - "__glXDispSwap_EvalCoord2fv", - "__glXDispSwap_EvalMesh1", - "__glXDispSwap_EvalMesh2", - "__glXDispSwap_EvalPoint1", - "__glXDispSwap_EvalPoint2", - "__glXDispSwap_FeedbackBuffer", - "__glXDispSwap_Finish", - "__glXDispSwap_Flush", - "__glXDispSwap_Fogf", - "__glXDispSwap_Fogfv", - "__glXDispSwap_Fogi", - "__glXDispSwap_Fogiv", - "__glXDispSwap_FrontFace", - "__glXDispSwap_Frustum", - "__glXDispSwap_GenLists", - "__glXDispSwap_GenTextures", - "__glXDispSwap_GenTexturesEXT", - "__glXDispSwap_GetBooleanv", - "__glXDispSwap_GetClipPlane", - "__glXDispSwap_GetColorTable", - "__glXDispSwap_GetColorTableParameterfv", - "__glXDispSwap_GetColorTableParameteriv", - "__glXDispSwap_GetConvolutionFilter", - "__glXDispSwap_GetConvolutionParameterfv", - "__glXDispSwap_GetConvolutionParameteriv", - "__glXDispSwap_GetDoublev", - "__glXDispSwap_GetError", - "__glXDispSwap_GetFloatv", - "__glXDispSwap_GetHistogram", - "__glXDispSwap_GetHistogramParameterfv", - "__glXDispSwap_GetHistogramParameteriv", - "__glXDispSwap_GetIntegerv", - "__glXDispSwap_GetLightfv", - "__glXDispSwap_GetLightiv", - "__glXDispSwap_GetMapdv", - "__glXDispSwap_GetMapfv", - "__glXDispSwap_GetMapiv", - "__glXDispSwap_GetMaterialfv", - "__glXDispSwap_GetMaterialiv", - "__glXDispSwap_GetMinmax", - "__glXDispSwap_GetMinmaxParameterfv", - "__glXDispSwap_GetMinmaxParameteriv", - "__glXDispSwap_GetPixelMapfv", - "__glXDispSwap_GetPixelMapuiv", - "__glXDispSwap_GetPixelMapusv", - "__glXDispSwap_GetPolygonStipple", - "__glXDispSwap_GetSeparableFilter", - "__glXDispSwap_GetString", - "__glXDispSwap_GetTexEnvfv", - "__glXDispSwap_GetTexEnviv", - "__glXDispSwap_GetTexGendv", - "__glXDispSwap_GetTexGenfv", - "__glXDispSwap_GetTexGeniv", - "__glXDispSwap_GetTexImage", - "__glXDispSwap_GetTexLevelParameterfv", - "__glXDispSwap_GetTexLevelParameteriv", - "__glXDispSwap_GetTexParameterfv", - "__glXDispSwap_GetTexParameteriv", - "__glXDispSwap_Hint", - "__glXDispSwap_Histogram", - "__glXDispSwap_IndexMask", - "__glXDispSwap_Indexdv", - "__glXDispSwap_Indexfv", - "__glXDispSwap_Indexiv", - "__glXDispSwap_Indexsv", - "__glXDispSwap_Indexubv", - "__glXDispSwap_InitNames", - "__glXDispSwap_IsEnabled", - "__glXDispSwap_IsList", - "__glXDispSwap_IsTexture", - "__glXDispSwap_IsTextureEXT", - "__glXDispSwap_LightModelf", - "__glXDispSwap_LightModelfv", - "__glXDispSwap_LightModeli", - "__glXDispSwap_LightModeliv", - "__glXDispSwap_Lightf", - "__glXDispSwap_Lightfv", - "__glXDispSwap_Lighti", - "__glXDispSwap_Lightiv", - "__glXDispSwap_LineStipple", - "__glXDispSwap_LineWidth", - "__glXDispSwap_ListBase", - "__glXDispSwap_LoadIdentity", - "__glXDispSwap_LoadMatrixd", - "__glXDispSwap_LoadMatrixf", - "__glXDispSwap_LoadName", - "__glXDispSwap_LogicOp", - "__glXDispSwap_Map1d", - "__glXDispSwap_Map1f", - "__glXDispSwap_Map2d", - "__glXDispSwap_Map2f", - "__glXDispSwap_MapGrid1d", - "__glXDispSwap_MapGrid1f", - "__glXDispSwap_MapGrid2d", - "__glXDispSwap_MapGrid2f", - "__glXDispSwap_Materialf", - "__glXDispSwap_Materialfv", - "__glXDispSwap_Materiali", - "__glXDispSwap_Materialiv", - "__glXDispSwap_MatrixMode", - "__glXDispSwap_Minmax", - "__glXDispSwap_MultMatrixd", - "__glXDispSwap_MultMatrixf", - "__glXDispSwap_MultiTexCoord1dvARB", - "__glXDispSwap_MultiTexCoord1fvARB", - "__glXDispSwap_MultiTexCoord1ivARB", - "__glXDispSwap_MultiTexCoord1svARB", - "__glXDispSwap_MultiTexCoord2dvARB", - "__glXDispSwap_MultiTexCoord2fvARB", - "__glXDispSwap_MultiTexCoord2ivARB", - "__glXDispSwap_MultiTexCoord2svARB", - "__glXDispSwap_MultiTexCoord3dvARB", - "__glXDispSwap_MultiTexCoord3fvARB", - "__glXDispSwap_MultiTexCoord3ivARB", - "__glXDispSwap_MultiTexCoord3svARB", - "__glXDispSwap_MultiTexCoord4dvARB", - "__glXDispSwap_MultiTexCoord4fvARB", - "__glXDispSwap_MultiTexCoord4ivARB", - "__glXDispSwap_MultiTexCoord4svARB", - "__glXDispSwap_NewList", - "__glXDispSwap_Normal3bv", - "__glXDispSwap_Normal3dv", - "__glXDispSwap_Normal3fv", - "__glXDispSwap_Normal3iv", - "__glXDispSwap_Normal3sv", - "__glXDispSwap_Ortho", - "__glXDispSwap_PassThrough", - "__glXDispSwap_PixelMapfv", - "__glXDispSwap_PixelMapuiv", - "__glXDispSwap_PixelMapusv", - "__glXDispSwap_PixelStoref", - "__glXDispSwap_PixelStorei", - "__glXDispSwap_PixelTransferf", - "__glXDispSwap_PixelTransferi", - "__glXDispSwap_PixelZoom", - "__glXDispSwap_PointParameterfARB", - "__glXDispSwap_PointParameterfvARB", - "__glXDispSwap_PointSize", - "__glXDispSwap_PolygonMode", - "__glXDispSwap_PolygonOffset", - "__glXDispSwap_PolygonStipple", - "__glXDispSwap_PopAttrib", - "__glXDispSwap_PopMatrix", - "__glXDispSwap_PopName", - "__glXDispSwap_PrioritizeTextures", - "__glXDispSwap_PushAttrib", - "__glXDispSwap_PushMatrix", - "__glXDispSwap_PushName", - "__glXDispSwap_RasterPos2dv", - "__glXDispSwap_RasterPos2fv", - "__glXDispSwap_RasterPos2iv", - "__glXDispSwap_RasterPos2sv", - "__glXDispSwap_RasterPos3dv", - "__glXDispSwap_RasterPos3fv", - "__glXDispSwap_RasterPos3iv", - "__glXDispSwap_RasterPos3sv", - "__glXDispSwap_RasterPos4dv", - "__glXDispSwap_RasterPos4fv", - "__glXDispSwap_RasterPos4iv", - "__glXDispSwap_RasterPos4sv", - "__glXDispSwap_ReadBuffer", - "__glXDispSwap_ReadPixels", - "__glXDispSwap_Rectdv", - "__glXDispSwap_Rectfv", - "__glXDispSwap_Rectiv", - "__glXDispSwap_Rectsv", - "__glXDispSwap_RenderMode", - "__glXDispSwap_ResetHistogram", - "__glXDispSwap_ResetMinmax", - "__glXDispSwap_Rotated", - "__glXDispSwap_Rotatef", - "__glXDispSwap_Scaled", - "__glXDispSwap_Scalef", - "__glXDispSwap_Scissor", - "__glXDispSwap_SelectBuffer", - "__glXDispSwap_SeparableFilter2D", - "__glXDispSwap_ShadeModel", - "__glXDispSwap_StencilFunc", - "__glXDispSwap_StencilMask", - "__glXDispSwap_StencilOp", - "__glXDispSwap_TexCoord1dv", - "__glXDispSwap_TexCoord1fv", - "__glXDispSwap_TexCoord1iv", - "__glXDispSwap_TexCoord1sv", - "__glXDispSwap_TexCoord2dv", - "__glXDispSwap_TexCoord2fv", - "__glXDispSwap_TexCoord2iv", - "__glXDispSwap_TexCoord2sv", - "__glXDispSwap_TexCoord3dv", - "__glXDispSwap_TexCoord3fv", - "__glXDispSwap_TexCoord3iv", - "__glXDispSwap_TexCoord3sv", - "__glXDispSwap_TexCoord4dv", - "__glXDispSwap_TexCoord4fv", - "__glXDispSwap_TexCoord4iv", - "__glXDispSwap_TexCoord4sv", - "__glXDispSwap_TexEnvf", - "__glXDispSwap_TexEnvfv", - "__glXDispSwap_TexEnvi", - "__glXDispSwap_TexEnviv", - "__glXDispSwap_TexGend", - "__glXDispSwap_TexGendv", - "__glXDispSwap_TexGenf", - "__glXDispSwap_TexGenfv", - "__glXDispSwap_TexGeni", - "__glXDispSwap_TexGeniv", - "__glXDispSwap_TexImage1D", - "__glXDispSwap_TexImage2D", - "__glXDispSwap_TexImage3D", - "__glXDispSwap_TexParameterf", - "__glXDispSwap_TexParameterfv", - "__glXDispSwap_TexParameteri", - "__glXDispSwap_TexParameteriv", - "__glXDispSwap_TexSubImage1D", - "__glXDispSwap_TexSubImage2D", - "__glXDispSwap_TexSubImage3D", - "__glXDispSwap_Translated", - "__glXDispSwap_Translatef", - "__glXDispSwap_Vertex2dv", - "__glXDispSwap_Vertex2fv", - "__glXDispSwap_Vertex2iv", - "__glXDispSwap_Vertex2sv", - "__glXDispSwap_Vertex3dv", - "__glXDispSwap_Vertex3fv", - "__glXDispSwap_Vertex3iv", - "__glXDispSwap_Vertex3sv", - "__glXDispSwap_Vertex4dv", - "__glXDispSwap_Vertex4fv", - "__glXDispSwap_Vertex4iv", - "__glXDispSwap_Vertex4sv", - "__glXDispSwap_Viewport", - "__glXDispSwap_WindowPos3fARB", - "__glXDisp_Accum", - "__glXDisp_ActiveStencilFaceEXT", - "__glXDisp_ActiveTextureARB", - "__glXDisp_AlphaFunc", - "__glXDisp_AreTexturesResident", - "__glXDisp_AreTexturesResidentEXT", - "__glXDisp_Begin", - "__glXDisp_BindTexture", - "__glXDisp_Bitmap", - "__glXDisp_BlendColor", - "__glXDisp_BlendEquation", - "__glXDisp_BlendFunc", - "__glXDisp_CallList", - "__glXDisp_CallLists", - "__glXDisp_Clear", - "__glXDisp_ClearAccum", - "__glXDisp_ClearColor", - "__glXDisp_ClearDepth", - "__glXDisp_ClearIndex", - "__glXDisp_ClearStencil", - "__glXDisp_ClipPlane", - "__glXDisp_Color3bv", - "__glXDisp_Color3dv", - "__glXDisp_Color3fv", - "__glXDisp_Color3iv", - "__glXDisp_Color3sv", - "__glXDisp_Color3ubv", - "__glXDisp_Color3uiv", - "__glXDisp_Color3usv", - "__glXDisp_Color4bv", - "__glXDisp_Color4dv", - "__glXDisp_Color4fv", - "__glXDisp_Color4iv", - "__glXDisp_Color4sv", - "__glXDisp_Color4ubv", - "__glXDisp_Color4uiv", - "__glXDisp_Color4usv", - "__glXDisp_ColorMask", - "__glXDisp_ColorMaterial", - "__glXDisp_ColorSubTable", - "__glXDisp_ColorTable", - "__glXDisp_ColorTableParameterfv", - "__glXDisp_ColorTableParameteriv", - "__glXDisp_ConvolutionFilter1D", - "__glXDisp_ConvolutionFilter2D", - "__glXDisp_ConvolutionParameterf", - "__glXDisp_ConvolutionParameterfv", - "__glXDisp_ConvolutionParameteri", - "__glXDisp_ConvolutionParameteriv", - "__glXDisp_CopyColorSubTable", - "__glXDisp_CopyColorTable", - "__glXDisp_CopyConvolutionFilter1D", - "__glXDisp_CopyConvolutionFilter2D", - "__glXDisp_CopyPixels", - "__glXDisp_CopyTexImage1D", - "__glXDisp_CopyTexImage2D", - "__glXDisp_CopyTexSubImage1D", - "__glXDisp_CopyTexSubImage2D", - "__glXDisp_CopyTexSubImage3D", - "__glXDisp_CullFace", - "__glXDisp_DeleteLists", - "__glXDisp_DeleteTextures", - "__glXDisp_DeleteTexturesEXT", - "__glXDisp_DepthFunc", - "__glXDisp_DepthMask", - "__glXDisp_DepthRange", - "__glXDisp_Disable", - "__glXDisp_DrawArrays", - "__glXDisp_DrawArraysEXT", - "__glXDisp_DrawBuffer", - "__glXDisp_DrawPixels", - "__glXDisp_EdgeFlagv", - "__glXDisp_Enable", - "__glXDisp_End", - "__glXDisp_EndList", - "__glXDisp_EvalCoord1dv", - "__glXDisp_EvalCoord1fv", - "__glXDisp_EvalCoord2dv", - "__glXDisp_EvalCoord2fv", - "__glXDisp_EvalMesh1", - "__glXDisp_EvalMesh2", - "__glXDisp_EvalPoint1", - "__glXDisp_EvalPoint2", - "__glXDisp_FeedbackBuffer", - "__glXDisp_Finish", - "__glXDisp_Flush", - "__glXDisp_Fogf", - "__glXDisp_Fogfv", - "__glXDisp_Fogi", - "__glXDisp_Fogiv", - "__glXDisp_FrontFace", - "__glXDisp_Frustum", - "__glXDisp_GenLists", - "__glXDisp_GenTextures", - "__glXDisp_GenTexturesEXT", - "__glXDisp_GetBooleanv", - "__glXDisp_GetClipPlane", - "__glXDisp_GetColorTable", - "__glXDisp_GetColorTableParameterfv", - "__glXDisp_GetColorTableParameteriv", - "__glXDisp_GetConvolutionFilter", - "__glXDisp_GetConvolutionParameterfv", - "__glXDisp_GetConvolutionParameteriv", - "__glXDisp_GetDoublev", - "__glXDisp_GetError", - "__glXDisp_GetFloatv", - "__glXDisp_GetHistogram", - "__glXDisp_GetHistogramParameterfv", - "__glXDisp_GetHistogramParameteriv", - "__glXDisp_GetIntegerv", - "__glXDisp_GetLightfv", - "__glXDisp_GetLightiv", - "__glXDisp_GetMapdv", - "__glXDisp_GetMapfv", - "__glXDisp_GetMapiv", - "__glXDisp_GetMaterialfv", - "__glXDisp_GetMaterialiv", - "__glXDisp_GetMinmax", - "__glXDisp_GetMinmaxParameterfv", - "__glXDisp_GetMinmaxParameteriv", - "__glXDisp_GetPixelMapfv", - "__glXDisp_GetPixelMapuiv", - "__glXDisp_GetPixelMapusv", - "__glXDisp_GetPolygonStipple", - "__glXDisp_GetSeparableFilter", - "__glXDisp_GetString", - "__glXDisp_GetTexEnvfv", - "__glXDisp_GetTexEnviv", - "__glXDisp_GetTexGendv", - "__glXDisp_GetTexGenfv", - "__glXDisp_GetTexGeniv", - "__glXDisp_GetTexImage", - "__glXDisp_GetTexLevelParameterfv", - "__glXDisp_GetTexLevelParameteriv", - "__glXDisp_GetTexParameterfv", - "__glXDisp_GetTexParameteriv", - "__glXDisp_Hint", - "__glXDisp_Histogram", - "__glXDisp_IndexMask", - "__glXDisp_Indexdv", - "__glXDisp_Indexfv", - "__glXDisp_Indexiv", - "__glXDisp_Indexsv", - "__glXDisp_Indexubv", - "__glXDisp_InitNames", - "__glXDisp_IsEnabled", - "__glXDisp_IsList", - "__glXDisp_IsTexture", - "__glXDisp_IsTextureEXT", - "__glXDisp_LightModelf", - "__glXDisp_LightModelfv", - "__glXDisp_LightModeli", - "__glXDisp_LightModeliv", - "__glXDisp_Lightf", - "__glXDisp_Lightfv", - "__glXDisp_Lighti", - "__glXDisp_Lightiv", - "__glXDisp_LineStipple", - "__glXDisp_LineWidth", - "__glXDisp_ListBase", - "__glXDisp_LoadIdentity", - "__glXDisp_LoadMatrixd", - "__glXDisp_LoadMatrixf", - "__glXDisp_LoadName", - "__glXDisp_LogicOp", - "__glXDisp_Map1d", - "__glXDisp_Map1f", - "__glXDisp_Map2d", - "__glXDisp_Map2f", - "__glXDisp_MapGrid1d", - "__glXDisp_MapGrid1f", - "__glXDisp_MapGrid2d", - "__glXDisp_MapGrid2f", - "__glXDisp_Materialf", - "__glXDisp_Materialfv", - "__glXDisp_Materiali", - "__glXDisp_Materialiv", - "__glXDisp_MatrixMode", - "__glXDisp_Minmax", - "__glXDisp_MultMatrixd", - "__glXDisp_MultMatrixf", - "__glXDisp_MultiTexCoord1dvARB", - "__glXDisp_MultiTexCoord1fvARB", - "__glXDisp_MultiTexCoord1ivARB", - "__glXDisp_MultiTexCoord1svARB", - "__glXDisp_MultiTexCoord2dvARB", - "__glXDisp_MultiTexCoord2fvARB", - "__glXDisp_MultiTexCoord2ivARB", - "__glXDisp_MultiTexCoord2svARB", - "__glXDisp_MultiTexCoord3dvARB", - "__glXDisp_MultiTexCoord3fvARB", - "__glXDisp_MultiTexCoord3ivARB", - "__glXDisp_MultiTexCoord3svARB", - "__glXDisp_MultiTexCoord4dvARB", - "__glXDisp_MultiTexCoord4fvARB", - "__glXDisp_MultiTexCoord4ivARB", - "__glXDisp_MultiTexCoord4svARB", - "__glXDisp_NewList", - "__glXDisp_Normal3bv", - "__glXDisp_Normal3dv", - "__glXDisp_Normal3fv", - "__glXDisp_Normal3iv", - "__glXDisp_Normal3sv", - "__glXDisp_Ortho", - "__glXDisp_PassThrough", - "__glXDisp_PixelMapfv", - "__glXDisp_PixelMapuiv", - "__glXDisp_PixelMapusv", - "__glXDisp_PixelStoref", - "__glXDisp_PixelStorei", - "__glXDisp_PixelTransferf", - "__glXDisp_PixelTransferi", - "__glXDisp_PixelZoom", - "__glXDisp_PointParameterfARB", - "__glXDisp_PointParameterfvARB", - "__glXDisp_PointSize", - "__glXDisp_PolygonMode", - "__glXDisp_PolygonOffset", - "__glXDisp_PolygonStipple", - "__glXDisp_PopAttrib", - "__glXDisp_PopMatrix", - "__glXDisp_PopName", - "__glXDisp_PrioritizeTextures", - "__glXDisp_PushAttrib", - "__glXDisp_PushMatrix", - "__glXDisp_PushName", - "__glXDisp_RasterPos2dv", - "__glXDisp_RasterPos2fv", - "__glXDisp_RasterPos2iv", - "__glXDisp_RasterPos2sv", - "__glXDisp_RasterPos3dv", - "__glXDisp_RasterPos3fv", - "__glXDisp_RasterPos3iv", - "__glXDisp_RasterPos3sv", - "__glXDisp_RasterPos4dv", - "__glXDisp_RasterPos4fv", - "__glXDisp_RasterPos4iv", - "__glXDisp_RasterPos4sv", - "__glXDisp_ReadBuffer", - "__glXDisp_ReadPixels", - "__glXDisp_Rectdv", - "__glXDisp_Rectfv", - "__glXDisp_Rectiv", - "__glXDisp_Rectsv", - "__glXDisp_RenderMode", - "__glXDisp_ResetHistogram", - "__glXDisp_ResetMinmax", - "__glXDisp_Rotated", - "__glXDisp_Rotatef", - "__glXDisp_Scaled", - "__glXDisp_Scalef", - "__glXDisp_Scissor", - "__glXDisp_SelectBuffer", - "__glXDisp_SeparableFilter2D", - "__glXDisp_ShadeModel", - "__glXDisp_StencilFunc", - "__glXDisp_StencilMask", - "__glXDisp_StencilOp", - "__glXDisp_TexCoord1dv", - "__glXDisp_TexCoord1fv", - "__glXDisp_TexCoord1iv", - "__glXDisp_TexCoord1sv", - "__glXDisp_TexCoord2dv", - "__glXDisp_TexCoord2fv", - "__glXDisp_TexCoord2iv", - "__glXDisp_TexCoord2sv", - "__glXDisp_TexCoord3dv", - "__glXDisp_TexCoord3fv", - "__glXDisp_TexCoord3iv", - "__glXDisp_TexCoord3sv", - "__glXDisp_TexCoord4dv", - "__glXDisp_TexCoord4fv", - "__glXDisp_TexCoord4iv", - "__glXDisp_TexCoord4sv", - "__glXDisp_TexEnvf", - "__glXDisp_TexEnvfv", - "__glXDisp_TexEnvi", - "__glXDisp_TexEnviv", - "__glXDisp_TexGend", - "__glXDisp_TexGendv", - "__glXDisp_TexGenf", - "__glXDisp_TexGenfv", - "__glXDisp_TexGeni", - "__glXDisp_TexGeniv", - "__glXDisp_TexImage1D", - "__glXDisp_TexImage2D", - "__glXDisp_TexImage3D", - "__glXDisp_TexParameterf", - "__glXDisp_TexParameterfv", - "__glXDisp_TexParameteri", - "__glXDisp_TexParameteriv", - "__glXDisp_TexSubImage1D", - "__glXDisp_TexSubImage2D", - "__glXDisp_TexSubImage3D", - "__glXDisp_Translated", - "__glXDisp_Translatef", - "__glXDisp_Vertex2dv", - "__glXDisp_Vertex2fv", - "__glXDisp_Vertex2iv", - "__glXDisp_Vertex2sv", - "__glXDisp_Vertex3dv", - "__glXDisp_Vertex3fv", - "__glXDisp_Vertex3iv", - "__glXDisp_Vertex3sv", - "__glXDisp_Vertex4dv", - "__glXDisp_Vertex4fv", - "__glXDisp_Vertex4iv", - "__glXDisp_Vertex4sv", - "__glXDisp_Viewport", - "__glXDisp_WindowPos3fARB", - "__glXDrawArraysSize", - "__glXDrawPixelsReqSize", - "__glXDrawableRes", - "__glXErrorOccured", - "__glXFBInitDrawable", - "__glXFBMemSwapBuffers", - "__glXFindDrawablePrivate", - "__glXFogfvReqSize", - "__glXFogivReqSize", - "__glXForceCurrent", - "__glXFree", - "__glXFreeBuffers", - "__glXFreeContext", - "__glXGetDrawablePrivate", - "__glXGetVisualConfigs", - "__glXImageSize", - "__glXImpAtoi", - "__glXImpCalloc", - "__glXImpFatal", - "__glXImpFclose", - "__glXImpFopen", - "__glXImpFprintf", - "__glXImpFree", - "__glXImpGetDrawablePrivate", - "__glXImpGetenv", - "__glXImpMalloc", - "__glXImpRealloc", - "__glXImpSprintf", - "__glXImpWarning", - "__glXInitFB", - "__glXInitMem", - "__glXInitPix", - "__glXIsDirect", - "__glXLastContext", - "__glXLightModelfvReqSize", - "__glXLightModelivReqSize", - "__glXLightfvReqSize", - "__glXLightivReqSize", - "__glXLookupContextByTag", - "__glXMakeCurrent", - "__glXMalloc", - "__glXMap1dReqSize", - "__glXMap1fReqSize", - "__glXMap2dReqSize", - "__glXMap2fReqSize", - "__glXMaterialfvReqSize", - "__glXMaterialivReqSize", - "__glXNoSuchRenderOpcode", - "__glXNoSuchSingleOpcode", - "__glXNop", - "__glXPixInitDrawable", - "__glXPixelMapfvReqSize", - "__glXPixelMapuivReqSize", - "__glXPixelMapusvReqSize", - "__glXPixmapRes", - "__glXPrioritizeTexturesReqSize", - "__glXQueryContextInfoEXT", - "__glXQueryExtensionsString", - "__glXQueryServerString", - "__glXQueryVersion", - "__glXRealloc", - "__glXRender", - "__glXRenderLarge", - "__glXRenderSizeTable", - "__glXRenderSizeTable_EXT", - "__glXRenderTable", - "__glXRenderTable_EXT", - "__glXReply", - "__glXResetLargeCommandStatus", - "__glXResizeBuffers", - "__glXResizeDrawableBuffers", - "__glXScreenInit", - "__glXScreenReset", - "__glXSeparableFilter2DReqSize", - "__glXSingleTable", - "__glXSwapBuffers", - "__glXSwapClientInfo", - "__glXSwapCopyContext", - "__glXSwapCreateContext", - "__glXSwapCreateGLXPixmap", - "__glXSwapDestroyContext", - "__glXSwapDestroyGLXPixmap", - "__glXSwapGetVisualConfigs", - "__glXSwapIsDirect", - "__glXSwapIsDirectReply", - "__glXSwapMakeCurrent", - "__glXSwapMakeCurrentReply", - "__glXSwapQueryContextInfoEXTReply", - "__glXSwapQueryExtensionsString", - "__glXSwapQueryServerString", - "__glXSwapQueryVersion", - "__glXSwapQueryVersionReply", - "__glXSwapRender", - "__glXSwapRenderLarge", - "__glXSwapRenderTable", - "__glXSwapRenderTable_EXT", - "__glXSwapSingleTable", - "__glXSwapSwapBuffers", - "__glXSwapUseXFont", - "__glXSwapVendorPrivTable_EXT", - "__glXSwapVendorPrivate", - "__glXSwapVendorPrivateWithReply", - "__glXSwapWaitGL", - "__glXSwapWaitX", - "__glXTexEnvfvReqSize", - "__glXTexEnvivReqSize", - "__glXTexGendvReqSize", - "__glXTexGenfvReqSize", - "__glXTexGenivReqSize", - "__glXTexImage1DReqSize", - "__glXTexImage2DReqSize", - "__glXTexImage3DReqSize", - "__glXTexParameterfvReqSize", - "__glXTexParameterivReqSize", - "__glXTexSubImage1DReqSize", - "__glXTexSubImage2DReqSize", - "__glXTexSubImage3DReqSize", - "__glXTypeSize", - "__glXUnrefDrawablePrivate", - "__glXUnsupportedPrivateRequest", - "__glXUseXFont", - "__glXVendorPrivTable_EXT", - "__glXVendorPrivate", - "__glXVendorPrivateWithReply", - "__glXWaitGL", - "__glXWaitX", - "__glXcombine_strings", - "glAccum", - "glActiveStencilFaceEXT", - "glActiveTextureARB", - "glAlphaFunc", - "glAreTexturesResident", - "glAreTexturesResidentEXT", - "glBegin", - "glBindTexture", - "glBitmap", - "glBlendColor", - "glBlendEquation", - "glBlendFunc", - "glCallList", - "glCallLists", - "glClear", - "glClearAccum", - "glClearColor", - "glClearDepth", - "glClearIndex", - "glClearStencil", - "glClipPlane", - "glColor3bv", - "glColor3dv", - "glColor3fv", - "glColor3iv", - "glColor3sv", - "glColor3ubv", - "glColor3uiv", - "glColor3usv", - "glColor4bv", - "glColor4dv", - "glColor4fv", - "glColor4iv", - "glColor4sv", - "glColor4ubv", - "glColor4uiv", - "glColor4usv", - "glColorMask", - "glColorMaterial", - "glColorPointer", - "glColorSubTable", - "glColorTable", - "glColorTableParameterfv", - "glColorTableParameteriv", - "glConvolutionFilter1D", - "glConvolutionFilter2D", - "glConvolutionParameterf", - "glConvolutionParameterfv", - "glConvolutionParameteri", - "glConvolutionParameteriv", - "glCopyColorSubTable", - "glCopyColorTable", - "glCopyConvolutionFilter1D", - "glCopyConvolutionFilter2D", - "glCopyPixels", - "glCopyTexImage1D", - "glCopyTexImage2D", - "glCopyTexSubImage1D", - "glCopyTexSubImage2D", - "glCopyTexSubImage3D", - "glCullFace", - "glDeleteLists", - "glDeleteTextures", - "glDeleteTexturesEXT", - "glDepthFunc", - "glDepthMask", - "glDepthRange", - "glDisable", - "glDisableClientState", - "glDrawArrays", - "glDrawBuffer", - "glDrawPixels", - "glEdgeFlagPointer", - "glEdgeFlagv", - "glEnable", - "glEnableClientState", - "glEnd", - "glEndList", - "glEvalCoord1dv", - "glEvalCoord1fv", - "glEvalCoord2dv", - "glEvalCoord2fv", - "glEvalMesh1", - "glEvalMesh2", - "glEvalPoint1", - "glEvalPoint2", - "glFeedbackBuffer", - "glFinish", - "glFlush", - "glFogf", - "glFogfv", - "glFogi", - "glFogiv", - "glFrontFace", - "glFrustum", - "glGenLists", - "glGenTextures", - "glGenTexturesEXT", - "glGetBooleanv", - "glGetClipPlane", - "glGetColorTable", - "glGetColorTableParameterfv", - "glGetColorTableParameteriv", - "glGetConvolutionFilter", - "glGetConvolutionParameterfv", - "glGetConvolutionParameteriv", - "glGetDoublev", - "glGetError", - "glGetFloatv", - "glGetHistogram", - "glGetHistogramParameterfv", - "glGetHistogramParameteriv", - "glGetIntegerv", - "glGetLightfv", - "glGetLightiv", - "glGetMapdv", - "glGetMapfv", - "glGetMapiv", - "glGetMaterialfv", - "glGetMaterialiv", - "glGetMinmax", - "glGetMinmaxParameterfv", - "glGetMinmaxParameteriv", - "glGetPixelMapfv", - "glGetPixelMapuiv", - "glGetPixelMapusv", - "glGetPolygonStipple", - "glGetSeparableFilter", - "glGetString", - "glGetTexEnvfv", - "glGetTexEnviv", - "glGetTexGendv", - "glGetTexGenfv", - "glGetTexGeniv", - "glGetTexImage", - "glGetTexLevelParameterfv", - "glGetTexLevelParameteriv", - "glGetTexParameterfv", - "glGetTexParameteriv", - "glHint", - "glHistogram", - "glIndexMask", - "glIndexPointer", - "glIndexdv", - "glIndexfv", - "glIndexiv", - "glIndexsv", - "glIndexubv", - "glInitNames", - "glIsEnabled", - "glIsList", - "glIsTexture", - "glIsTextureEXT", - "glLightModelf", - "glLightModelfv", - "glLightModeli", - "glLightModeliv", - "glLightf", - "glLightfv", - "glLighti", - "glLightiv", - "glLineStipple", - "glLineWidth", - "glListBase", - "glLoadIdentity", - "glLoadMatrixd", - "glLoadMatrixf", - "glLoadName", - "glLogicOp", - "glMap1d", - "glMap1f", - "glMap2d", - "glMap2f", - "glMapGrid1d", - "glMapGrid1f", - "glMapGrid2d", - "glMapGrid2f", - "glMaterialf", - "glMaterialfv", - "glMateriali", - "glMaterialiv", - "glMatrixMode", - "glMinmax", - "glMultMatrixd", - "glMultMatrixf", - "glMultiTexCoord1dvARB", - "glMultiTexCoord1fvARB", - "glMultiTexCoord1ivARB", - "glMultiTexCoord1svARB", - "glMultiTexCoord2dvARB", - "glMultiTexCoord2fvARB", - "glMultiTexCoord2ivARB", - "glMultiTexCoord2svARB", - "glMultiTexCoord3dvARB", - "glMultiTexCoord3fvARB", - "glMultiTexCoord3ivARB", - "glMultiTexCoord3svARB", - "glMultiTexCoord4dvARB", - "glMultiTexCoord4fvARB", - "glMultiTexCoord4ivARB", - "glMultiTexCoord4svARB", - "glNewList", - "glNormal3bv", - "glNormal3dv", - "glNormal3fv", - "glNormal3iv", - "glNormal3sv", - "glNormalPointer", - "glOrtho", - "glPassThrough", - "glPixelMapfv", - "glPixelMapuiv", - "glPixelMapusv", - "glPixelStoref", - "glPixelStorei", - "glPixelTransferf", - "glPixelTransferi", - "glPixelZoom", - "glPointParameterfARB", - "glPointParameterfvARB", - "glPointSize", - "glPolygonMode", - "glPolygonOffset", - "glPolygonStipple", - "glPopAttrib", - "glPopMatrix", - "glPopName", - "glPrioritizeTextures", - "glPushAttrib", - "glPushMatrix", - "glPushName", - "glRasterPos2dv", - "glRasterPos2fv", - "glRasterPos2iv", - "glRasterPos2sv", - "glRasterPos3dv", - "glRasterPos3fv", - "glRasterPos3iv", - "glRasterPos3sv", - "glRasterPos4dv", - "glRasterPos4fv", - "glRasterPos4iv", - "glRasterPos4sv", - "glReadBuffer", - "glReadPixels", - "glRectdv", - "glRectfv", - "glRectiv", - "glRectsv", - "glRenderMode", - "glResetHistogram", - "glResetMinmax", - "glRotated", - "glRotatef", - "glScaled", - "glScalef", - "glScissor", - "glSelectBuffer", - "glSeparableFilter2D", - "glShadeModel", - "glStencilFunc", - "glStencilMask", - "glStencilOp", - "glTexCoord1dv", - "glTexCoord1fv", - "glTexCoord1iv", - "glTexCoord1sv", - "glTexCoord2dv", - "glTexCoord2fv", - "glTexCoord2iv", - "glTexCoord2sv", - "glTexCoord3dv", - "glTexCoord3fv", - "glTexCoord3iv", - "glTexCoord3sv", - "glTexCoord4dv", - "glTexCoord4fv", - "glTexCoord4iv", - "glTexCoord4sv", - "glTexCoordPointer", - "glTexEnvf", - "glTexEnvfv", - "glTexEnvi", - "glTexEnviv", - "glTexGend", - "glTexGendv", - "glTexGenf", - "glTexGenfv", - "glTexGeni", - "glTexGeniv", - "glTexImage1D", - "glTexImage2D", - "glTexImage3D", - "glTexParameterf", - "glTexParameterfv", - "glTexParameteri", - "glTexParameteriv", - "glTexSubImage1D", - "glTexSubImage2D", - "glTexSubImage3D", - "glTranslated", - "glTranslatef", - "glVertex2dv", - "glVertex2fv", - "glVertex2iv", - "glVertex2sv", - "glVertex3dv", - "glVertex3fv", - "glVertex3iv", - "glVertex3sv", - "glVertex4dv", - "glVertex4fv", - "glVertex4iv", - "glVertex4sv", - "glVertexPointer", - "glViewport", - "glWindowPos3fARB", - "glxSwapQueryExtensionsStringReply", - "glxSwapQueryServerStringReply", - NULL -}; - static XF86ModuleVersionInfo VersRec = { "glx", @@ -1236,35 +84,68 @@ static XF86ModuleVersionInfo VersRec = XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL }; +/* We do a little proxy dance here, so we can avoid loading GLcore + * unless we really need to.*/ + +static pointer glxModule; + +static __GLXscreen * +__glXMesaProxyScreenProbe(ScreenPtr pScreen) +{ + pointer GLcore; + static __GLXprovider *provider; + + if (provider == NULL) { + GLcore = LoadSubModuleLocal(glxModule, "GLcore", NULL, NULL, NULL, NULL, + NULL, NULL); + if (GLcore == NULL) + return NULL; + + provider = LoaderSymbol("__glXMesaProvider"); + if (provider == NULL) + return NULL; + } + + return provider->screenProbe(pScreen); +} + +static __GLXprovider __glXMesaProxyProvider = { + __glXMesaProxyScreenProbe, + "MESA-PROXY", + NULL +}; + + static pointer glxSetup(pointer module, pointer opts, int *errmaj, int *errmin) { static Bool setupDone = FALSE; - pointer GLcore = NULL; -#ifdef GLX_USE_SGI_SI - char GLcoreName[] = "GL"; -#else - char GLcoreName[] = "GLcore"; -#endif + __GLXprovider *provider; - if (!setupDone) { - setupDone = TRUE; - - GLcore = LoadSubModule(module, GLcoreName, NULL, NULL, NULL, NULL, - errmaj, errmin); - if (!GLcore) { - if (errmaj) *errmaj = LDR_NOSUBENT; - } else { - LoaderReqSymLists(glcoreSymbols, NULL); - LoadExtension(&GLXExt, FALSE); - /* Wrap the init visuals routine in micmap.c */ - GlxWrapInitVisuals(&miInitVisualsProc); - /* Make sure this gets wrapped each time InitVisualWrap is called */ - miHookInitVisuals(NULL, GlxWrapInitVisuals); - } - } else { + if (setupDone) { if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } + + setupDone = TRUE; + + glxModule = module; + GlxPushProvider(&__glXMesaProxyProvider); + + xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n", + xf86Info.aiglx ? "enabled" : "disabled"); + if (xf86Info.aiglx) { + provider = LoaderSymbol("__glXDRIProvider"); + if (provider) + GlxPushProvider(provider); } - /* Need a non-NULL return value to indicate success */ - return GLcore; + + LoadExtension(&GLXExt, FALSE); + /* Wrap the init visuals routine in micmap.c */ + GlxWrapInitVisuals(&miInitVisualsProc); + /* Make sure this gets wrapped each time InitVisualWrap is called */ + miHookInitVisuals(NULL, GlxWrapInitVisuals); + + bail: + return module; } diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index dcd455ce0..8003f0df5 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -779,7 +779,7 @@ static Bool DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum); + __GLXscreen *pGLXScreen = __glXgetActiveScreen(pScreen->myNum); __GLcontextModes *modes = pGLXScreen->modes; void **pVisualConfigPriv = pGLXScreen->pVisualPriv; DRIContextPrivPtr pDRIContextPriv; @@ -843,7 +843,7 @@ DRICreateContext(ScreenPtr pScreen, VisualPtr visual, XID context, drm_context_t * pHWContext) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum); + __GLXscreen *pGLXScreen = __glXgetActiveScreen(pScreen->myNum); __GLcontextModes *modes = pGLXScreen->modes; void **pVisualConfigPriv = pGLXScreen->pVisualPriv; DRIContextPrivPtr pDRIContextPriv; diff --git a/hw/xfree86/loader/aoutloader.c b/hw/xfree86/loader/aoutloader.c index e03e80ef2..13500b93b 100644 --- a/hw/xfree86/loader/aoutloader.c +++ b/hw/xfree86/loader/aoutloader.c @@ -630,7 +630,7 @@ AOUT_GetSymbols(AOUTModulePtr aoutfile) * Public API for the a.out implementation of the loader */ void * -AOUTLoadModule(loaderPtr modrec, int aoutfd, LOOKUP ** ppLookup) +AOUTLoadModule(loaderPtr modrec, int aoutfd, LOOKUP ** ppLookup, int flags) { AOUTModulePtr aoutfile = NULL; AOUTHDR *header; diff --git a/hw/xfree86/loader/aoutloader.h b/hw/xfree86/loader/aoutloader.h index f906816f7..8c04a16eb 100644 --- a/hw/xfree86/loader/aoutloader.h +++ b/hw/xfree86/loader/aoutloader.h @@ -27,7 +27,7 @@ #ifndef _AOUTLOADER_H #define _AOUTLOADER_H -extern void *AOUTLoadModule(loaderPtr, int, LOOKUP **); +extern void *AOUTLoadModule(loaderPtr, int, LOOKUP **, int flags); extern void AOUTResolveSymbols(void *); extern int AOUTCheckForUnresolved(void *); extern char *AOUTAddressToSection(void *, unsigned long); diff --git a/hw/xfree86/loader/coffloader.c b/hw/xfree86/loader/coffloader.c index 298ca5d61..d29b39a72 100644 --- a/hw/xfree86/loader/coffloader.c +++ b/hw/xfree86/loader/coffloader.c @@ -1149,7 +1149,7 @@ COFFCollectSections(COFFModulePtr cofffile) * Public API for the COFF implementation of the loader. */ void * -COFFLoadModule(loaderPtr modrec, int cofffd, LOOKUP **ppLookup) +COFFLoadModule(loaderPtr modrec, int cofffd, LOOKUP **ppLookup, int flags) { COFFModulePtr cofffile; FILHDR *header; diff --git a/hw/xfree86/loader/coffloader.h b/hw/xfree86/loader/coffloader.h index 75cd542c8..0dc4720c3 100644 --- a/hw/xfree86/loader/coffloader.h +++ b/hw/xfree86/loader/coffloader.h @@ -30,7 +30,7 @@ #ifndef _COFFLOADER_H #define _COFFLOADER_H /* coffloader.c */ -extern void *COFFLoadModule(loaderPtr, int, LOOKUP **); +extern void *COFFLoadModule(loaderPtr, int, LOOKUP **, int flags); extern void COFFResolveSymbols(void *); extern int COFFCheckForUnresolved(void *); extern char *COFFAddressToSection(void *, unsigned long); diff --git a/hw/xfree86/loader/dlloader.c b/hw/xfree86/loader/dlloader.c index 224157d43..835deda49 100644 --- a/hw/xfree86/loader/dlloader.c +++ b/hw/xfree86/loader/dlloader.c @@ -63,8 +63,6 @@ #endif #endif -#define DLOPEN_FLAGS ( DLOPEN_LAZY | DLOPEN_GLOBAL ) - #if defined(CSRG_BASED) && !defined(__ELF__) #define NEED_UNDERSCORE_FOR_DLLSYM #endif @@ -76,6 +74,7 @@ typedef struct { int handle; void *dlhandle; + int flags; } DLModuleRec, *DLModulePtr; /* @@ -88,6 +87,28 @@ typedef struct DLModuleList { DLModuleList *dlModuleList = NULL; +void * +DLFindSymbolLocal(pointer module, const char *name) +{ + DLModulePtr dlfile = module; + void *p; + char *n; + +#ifdef NEED_UNDERSCORE_FOR_DLLSYM + static const char symPrefix[] = "_"; +#else + static const char symPrefix[] = ""; +#endif + + n = xf86loadermalloc(strlen(symPrefix) + strlen(name) + 1); + sprintf(n, "%s%s", symPrefix, name); + p = dlsym(dlfile->dlhandle, n); + xf86loaderfree(n); + + return p; +} + + /* * Search a symbol in the module list */ @@ -97,30 +118,11 @@ DLFindSymbol(const char *name) DLModuleList *l; void *p; -#ifdef NEED_UNDERSCORE_FOR_DLLSYM - char *n; - - n = xf86loadermalloc(strlen(name) + 2); - sprintf(n, "_%s", name); -#endif - - (void)dlerror(); /* Clear out any previous error */ for (l = dlModuleList; l != NULL; l = l->next) { -#ifdef NEED_UNDERSCORE_FOR_DLLSYM - p = dlsym(l->module->dlhandle, n); -#else - p = dlsym(l->module->dlhandle, name); -#endif - if (dlerror() == NULL) { -#ifdef NEED_UNDERSCORE_FOR_DLLSYM - xf86loaderfree(n); -#endif + p = DLFindSymbolLocal(l->module, name); + if (p) return p; - } } -#ifdef NEED_UNDERSCORE_FOR_DLLSYM - xf86loaderfree(n); -#endif return NULL; } @@ -129,23 +131,28 @@ DLFindSymbol(const char *name) * public interface */ void * -DLLoadModule(loaderPtr modrec, int fd, LOOKUP ** ppLookup) +DLLoadModule(loaderPtr modrec, int fd, LOOKUP ** ppLookup, int flags) { DLModulePtr dlfile; DLModuleList *l; + int dlopen_flags; if ((dlfile = xf86loadercalloc(1, sizeof(DLModuleRec))) == NULL) { ErrorF("Unable to allocate DLModuleRec\n"); return NULL; } dlfile->handle = modrec->handle; - dlfile->dlhandle = dlopen(modrec->name, DLOPEN_FLAGS); + if (flags & LD_FLAG_GLOBAL) + dlopen_flags = DLOPEN_LAZY | DLOPEN_GLOBAL; + else + dlopen_flags = DLOPEN_LAZY; + dlfile->dlhandle = dlopen(modrec->name, dlopen_flags); if (dlfile->dlhandle == NULL) { ErrorF("dlopen: %s\n", dlerror()); xf86loaderfree(dlfile); return NULL; } - /* Add it to the module list */ + l = xf86loadermalloc(sizeof(DLModuleList)); l->module = dlfile; l->next = dlModuleList; diff --git a/hw/xfree86/loader/dlloader.h b/hw/xfree86/loader/dlloader.h index 1dfae274d..6475291b5 100644 --- a/hw/xfree86/loader/dlloader.h +++ b/hw/xfree86/loader/dlloader.h @@ -27,10 +27,11 @@ #ifndef _DLLOADER_H #define _DLLOADER_H -extern void *DLLoadModule(loaderPtr, int, LOOKUP **); +extern void *DLLoadModule(loaderPtr, int, LOOKUP **, int flags); extern void DLResolveSymbols(void *); extern int DLCheckForUnresolved(void *); extern void DLUnloadModule(void *); extern void *DLFindSymbol(const char *name); +extern void *DLFindSymbolLocal(pointer module, const char *name); #endif diff --git a/hw/xfree86/loader/elfloader.c b/hw/xfree86/loader/elfloader.c index 39772cf69..bcc6686f4 100644 --- a/hw/xfree86/loader/elfloader.c +++ b/hw/xfree86/loader/elfloader.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.7 2005/04/23 19:01:13 ajax Exp $ */ +/* $XdotOrg: xserver/xorg/hw/xfree86/loader/elfloader.c,v 1.10.12.1 2006/02/24 05:49:34 krh Exp $ */ /* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.61tsi Exp $ */ /* @@ -2884,7 +2884,7 @@ ELFCollectSections(ELFModulePtr elffile, int pass, int *totalsize, * Public API for the ELF implementation of the loader. */ void * -ELFLoadModule(loaderPtr modrec, int elffd, LOOKUP **ppLookup) +ELFLoadModule(loaderPtr modrec, int elffd, LOOKUP **ppLookup, int flags) { ELFModulePtr elffile; Elf_Ehdr *header; diff --git a/hw/xfree86/loader/elfloader.h b/hw/xfree86/loader/elfloader.h index 6e9f02ca4..8cb09eeba 100644 --- a/hw/xfree86/loader/elfloader.h +++ b/hw/xfree86/loader/elfloader.h @@ -30,7 +30,7 @@ #ifndef _ELFLOADER_H #define _ELFLOADER_H /* elfloader.c */ -extern void *ELFLoadModule(loaderPtr, int, LOOKUP **); +extern void *ELFLoadModule(loaderPtr, int, LOOKUP **, int flags); extern void ELFResolveSymbols(void *); extern int ELFCheckForUnresolved(void *); extern char *ELFAddressToSection(void *, unsigned long); diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index 5a2c127d5..315926b18 100644 --- a/hw/xfree86/loader/loader.c +++ b/hw/xfree86/loader/loader.c @@ -973,7 +973,7 @@ _LoaderHandleUnresolved(char *symbol, char *module) * Handle an archive. */ void * -ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup) +ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup, int flags) { loaderPtr tmp = NULL; void *ret = NULL; @@ -1171,7 +1171,7 @@ ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup) } offsetbias = offset; - if ((tmp->private = funcs[modtype].LoadModule(tmp, arfd, &lookup_ret)) + if ((tmp->private = funcs[modtype].LoadModule(tmp, arfd, &lookup_ret, LD_FLAG_GLOBAL)) == NULL) { ErrorF("Failed to load %s\n", hdr.ar_name); offsetbias = 0; @@ -1233,13 +1233,14 @@ _LoaderGetRelocations(void *mod) return &(formatrec->pRelocs); } + /* * Public Interface to the loader. */ int LoaderOpen(const char *module, const char *cname, int handle, - int *errmaj, int *errmin, int *wasLoaded) + int *errmaj, int *errmin, int *wasLoaded, int flags) { loaderPtr tmp; int new_handle, modtype; @@ -1329,7 +1330,7 @@ LoaderOpen(const char *module, const char *cname, int handle, tmp->module = moduleseq++; tmp->funcs = &funcs[modtype]; - if ((tmp->private = funcs[modtype].LoadModule(tmp, fd, &pLookup)) == NULL) { + if ((tmp->private = funcs[modtype].LoadModule(tmp, fd, &pLookup, flags)) == NULL) { xf86Msg(X_ERROR, "Failed to load %s\n", module); _LoaderListPop(new_handle); freeHandles[new_handle] = HANDLE_FREE; diff --git a/hw/xfree86/loader/loader.h b/hw/xfree86/loader/loader.h index 307b9bb48..cc8b8f381 100644 --- a/hw/xfree86/loader/loader.h +++ b/hw/xfree86/loader/loader.h @@ -80,6 +80,11 @@ #define LD_PROCESSED_ARCHIVE -1 /* #define UNINIT_SECTION */ #define HANDLE_IN_HASH_ENTRY + +/* LoadModule proc flags; LD_FLAG_GLOBAL adds symbols to global + * namespace, default is to keep symbols local to module. */ +#define LD_FLAG_GLOBAL 1 + /* * COFF Section nmumbers */ @@ -193,7 +198,7 @@ typedef struct _loader *loaderPtr; * _loader_funcs hold the entry points for a module format. */ -typedef void *(*LoadModuleProcPtr) (loaderPtr modrec, int fd, LOOKUP **); +typedef void *(*LoadModuleProcPtr) (loaderPtr modrec, int fd, LOOKUP **, int flags); typedef void (*ResolveSymbolsProcPtr) (void *); typedef int (*CheckForUnresolvedProcPtr) (void *); typedef char *(*AddressToSectionProcPtr) (void *, unsigned long); @@ -256,7 +261,7 @@ void LoaderDumpSymbols(void); char *_LoaderModuleToName(int); int _LoaderAddressToSection(const unsigned long, const char **, const char **); -int LoaderOpen(const char *, const char *, int, int *, int *, int *); +int LoaderOpen(const char *, const char *, int, int *, int *, int *, int); int LoaderHandleOpen(int); /* @@ -285,7 +290,7 @@ char *_LoaderHandleToCanonicalName(int handle); #include "elfloader.h" #include "dlloader.h" /* LD_ARCHIVE */ -void *ARCHIVELoadModule(loaderPtr, int, LOOKUP **); +void *ARCHIVELoadModule(loaderPtr, int, LOOKUP **, int flags); extern void _loader_debug_state(void); diff --git a/hw/xfree86/loader/loaderProcs.h b/hw/xfree86/loader/loaderProcs.h index 72591a5df..19752abe3 100644 --- a/hw/xfree86/loader/loaderProcs.h +++ b/hw/xfree86/loader/loaderProcs.h @@ -92,6 +92,10 @@ ModuleDescPtr LoadModule(const char *, const char *, const char **, ModuleDescPtr LoadSubModule(ModuleDescPtr, const char *, const char **, const char **, pointer, const XF86ModReqInfo *, int *, int *); +ModuleDescPtr LoadSubModuleLocal(ModuleDescPtr, const char *, + const char **, const char **, + pointer, const XF86ModReqInfo *, + int *, int *); ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent); void LoadFont(FontModule *); void UnloadModule(ModuleDescPtr); diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 63b9b3d24..4316d424f 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -88,6 +88,10 @@ static Bool CheckVersion(const char *, XF86ModuleVersionInfo *, static void UnloadModuleOrDriver(ModuleDescPtr mod); static char *LoaderGetCanonicalName(const char *, PatternPtr); static void RemoveChild(ModuleDescPtr); +static ModuleDescPtr doLoadModule(const char *, const char *, const char **, + const char **, pointer, + const XF86ModReqInfo *, int *, int *, + int flags); ModuleVersions LoaderVersionInfo = { XORG_VERSION_CURRENT, @@ -782,8 +786,44 @@ LoadSubModule(ModuleDescPtr parent, const char *module, return NULL; } - submod = LoadModule(module, NULL, subdirlist, patternlist, options, - modreq, errmaj, errmin); + submod = doLoadModule(module, NULL, subdirlist, patternlist, options, + modreq, errmaj, errmin, LD_FLAG_GLOBAL); + if (submod) { + parent->child = AddSibling(parent->child, submod); + submod->parent = parent; + } + return submod; +} + +ModuleDescPtr +LoadSubModuleLocal(ModuleDescPtr parent, const char *module, + const char **subdirlist, const char **patternlist, + pointer options, const XF86ModReqInfo * modreq, + int *errmaj, int *errmin) +{ + ModuleDescPtr submod; + + xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module); + + /* Absolute module paths are not allowed here */ +#ifndef __UNIXOS2__ + if (module[0] == '/') +#else + if (isalpha(module[0]) && module[1] == ':' && module[2] == '/') +#endif + { + xf86Msg(X_ERROR, + "LoadSubModule: Absolute module path not permitted: \"%s\"\n", + module); + if (errmaj) + *errmaj = LDR_BADUSAGE; + if (errmin) + *errmin = 0; + return NULL; + } + + submod = doLoadModule(module, NULL, subdirlist, patternlist, options, + modreq, errmaj, errmin, 0); if (submod) { parent->child = AddSibling(parent->child, submod); submod->parent = parent; @@ -823,48 +863,12 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) return ret; } -/* - * LoadModule: load a module - * - * module The module name. Normally this is not a filename but the - * module's "canonical name. A full pathname is, however, - * also accepted. - * path A comma separated list of module directories. - * subdirlist A NULL terminated list of subdirectories to search. When - * NULL, the default "stdSubdirs" list is used. The default - * list is also substituted for entries with value DEFAULT_LIST. - * patternlist A NULL terminated list of regular expressions used to find - * module filenames. Each regex should contain exactly one - * subexpression that corresponds to the canonical module name. - * When NULL, the default "stdPatterns" list is used. The - * default list is also substituted for entries with value - * DEFAULT_LIST. - * options A NULL terminated list of Options that are passed to the - * module's SetupProc function. - * modreq An optional XF86ModReqInfo* containing - * version/ABI/vendor-ABI requirements to check for when - * loading the module. The following fields of the - * XF86ModReqInfo struct are checked: - * majorversion - must match the module's majorversion exactly - * minorversion - the module's minorversion must be >= this - * patchlevel - the module's minorversion.patchlevel must be - * >= this. Patchlevel is ignored when - * minorversion is not set. - * abiclass - (string) must match the module's abiclass - * abiversion - must be consistent with the module's - * abiversion (major equal, minor no older) - * moduleclass - string must match the module's moduleclass - * string - * "don't care" values are ~0 for numbers, and NULL for strings - * errmaj Major error return. - * errmin Minor error return. - * - */ -ModuleDescPtr -LoadModule(const char *module, const char *path, const char **subdirlist, - const char **patternlist, pointer options, - const XF86ModReqInfo * modreq, int *errmaj, int *errmin) +static ModuleDescPtr +doLoadModule(const char *module, const char *path, const char **subdirlist, + const char **patternlist, pointer options, + const XF86ModReqInfo * modreq, + int *errmaj, int *errmin, int flags) { XF86ModuleData *initdata = NULL; char **pathlist = NULL; @@ -957,7 +961,8 @@ LoadModule(const char *module, const char *path, const char **subdirlist, *errmin = 0; goto LoadModule_fail; } - ret->handle = LoaderOpen(found, name, 0, errmaj, errmin, &wasLoaded); + ret->handle = LoaderOpen(found, name, 0, + errmaj, errmin, &wasLoaded, flags); if (ret->handle < 0) goto LoadModule_fail; @@ -1066,6 +1071,52 @@ LoadModule(const char *module, const char *path, const char **subdirlist, return ret; } +/* + * LoadModule: load a module + * + * module The module name. Normally this is not a filename but the + * module's "canonical name. A full pathname is, however, + * also accepted. + * path A comma separated list of module directories. + * subdirlist A NULL terminated list of subdirectories to search. When + * NULL, the default "stdSubdirs" list is used. The default + * list is also substituted for entries with value DEFAULT_LIST. + * patternlist A NULL terminated list of regular expressions used to find + * module filenames. Each regex should contain exactly one + * subexpression that corresponds to the canonical module name. + * When NULL, the default "stdPatterns" list is used. The + * default list is also substituted for entries with value + * DEFAULT_LIST. + * options A NULL terminated list of Options that are passed to the + * module's SetupProc function. + * modreq An optional XF86ModReqInfo* containing + * version/ABI/vendor-ABI requirements to check for when + * loading the module. The following fields of the + * XF86ModReqInfo struct are checked: + * majorversion - must match the module's majorversion exactly + * minorversion - the module's minorversion must be >= this + * patchlevel - the module's minorversion.patchlevel must be + * >= this. Patchlevel is ignored when + * minorversion is not set. + * abiclass - (string) must match the module's abiclass + * abiversion - must be consistent with the module's + * abiversion (major equal, minor no older) + * moduleclass - string must match the module's moduleclass + * string + * "don't care" values are ~0 for numbers, and NULL for strings + * errmaj Major error return. + * errmin Minor error return. + * + */ +ModuleDescPtr +LoadModule(const char *module, const char *path, const char **subdirlist, + const char **patternlist, pointer options, + const XF86ModReqInfo * modreq, int *errmaj, int *errmin) +{ + return doLoadModule(module, path, subdirlist, patternlist, options, + modreq, errmaj, errmin, LD_FLAG_GLOBAL); +} + ModuleDescPtr LoadDriver(const char *module, const char *path, int handle, pointer options, int *errmaj, int *errmin) diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 0e3f8f985..f33e5827f 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -53,6 +53,12 @@ /* Build GLX extension */ #undef GLXEXT +/* Build GLX DRI loader */ +#undef GLX_DRI + +/* Path to DRI drivers */ +#undef DRI_DRIVER_PATH + /* Include handhelds.org h3600 touchscreen driver */ #undef H3600_TS diff --git a/mi/miinitext.c b/mi/miinitext.c index 5d7b0b079..7939a5f21 100644 --- a/mi/miinitext.c +++ b/mi/miinitext.c @@ -1,4 +1,4 @@ -/* $XdotOrg: xserver/xorg/mi/miinitext.c,v 1.30 2006/01/08 23:43:54 ajax Exp $ */ +/* $XdotOrg: xserver/xorg/mi/miinitext.c,v 1.31 2006/02/15 19:05:54 ajax Exp $ */ /* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.67 2003/01/12 02:44:27 dawes Exp $ */ /*********************************************************** @@ -350,6 +350,9 @@ extern void XFree86MiscExtensionInit(INITARGS); extern void XFree86DGAExtensionInit(INITARGS); #endif #ifdef GLXEXT +typedef struct __GLXprovider __GLXprovider; +extern __GLXprovider __glXMesaProvider; +extern void GlxPushProvider(__GLXprovider *impl); #ifndef __DARWIN__ extern void GlxExtensionInit(INITARGS); extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); @@ -643,6 +646,8 @@ InitExtensions(argc, argv) #endif #endif #ifdef GLXEXT + + GlxPushProvider(&__glXMesaProvider); #ifndef __DARWIN__ if (!noGlxExtension) GlxExtensionInit(); #else |