summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrianp <brianp>2002-11-16 00:13:46 +0000
committerbrianp <brianp>2002-11-16 00:13:46 +0000
commitbfe40750b0a55bffaed3ef2aae86defc4e10c4b0 (patch)
tree93123dde107c19a461a86b857445b1c44d8b5fb4
parentd881ce7f344ab6f46ae4197d0455a276c331ee4f (diff)
Modified functions in __DriverAPIRec to remove unneeded Display *radeon-20021122
parameters, etc. Generally try to reduce number of X dependencies within the driver code. Added driMajor/Minor/Patch fields to __DRIscreenPrivateRec and call XF86DRIQueryVersion in dri_util.c instead of in all the drivers. Lots of #include clean-ups.
-rw-r--r--xc/lib/GL/dri/dri_util.c1116
-rw-r--r--xc/lib/GL/dri/dri_util.h373
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_context.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c4
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c4
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_points.c9
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_state.c5
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c17
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_context.c4
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_context.h5
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h12
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c15
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_state.c1
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c8
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810context.c13
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810context.h3
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810ioctl.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810screen.c21
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810screen.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810state.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tex.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810texmem.c411
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810texstate.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tris.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_context.c16
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_context.h1
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_debug.c4
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_screen.c27
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_screen.h115
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_state.c1
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_texmem.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_texstate.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/i830/i830_tris.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c26
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgabuffers.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgacontext.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgadd.c4
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.c9
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgapixel.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgastate.c1
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatris.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgavb.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_lock.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.c23
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tris.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_context.c9
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_context.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_lock.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_pixel.c3
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_screen.c26
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_screen.h1
-rw-r--r--xc/lib/GL/mesa/src/drv/r200/r200_texstate.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_context.c11
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_context.h3
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c17
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_tcl.c1
-rw-r--r--xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c22
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h3
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c5
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c25
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c3
75 files changed, 2140 insertions, 338 deletions
diff --git a/xc/lib/GL/dri/dri_util.c b/xc/lib/GL/dri/dri_util.c
new file mode 100644
index 000000000..e06f3b4b4
--- /dev/null
+++ b/xc/lib/GL/dri/dri_util.c
@@ -0,0 +1,1116 @@
+/* $XFree86$ */
+/**************************************************************************
+
+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 PRECISION INSIGHT AND/OR ITS 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 E. Paul <brian@precisioninsight.com>
+ */
+
+/*
+ * This file gets compiled into each of the DRI 3D drivers. This is
+ * basically just a collection of utility functions that are useful
+ * for most drivers. A DRI driver doesn't have to use any of this,
+ * but it's useful boilerplate.
+ *
+ *
+ * Many of the functions defined here are called from the GL library
+ * via function pointers in the __DRIdisplayRec, __DRIscreenRec,
+ * __DRIcontextRec, __DRIdrawableRec structures defined in glxclient.h
+ *
+ * Those function pointers are initialized by code in this file.
+ * The process starts when libGL calls the __driCreateScreen() function
+ * at the end of this file.
+ *
+ * The above-mentioned DRI structures have no dependencies on Mesa.
+ * Each structure instead has a generic (void *) private pointer that
+ * points to a private structure. For the current drivers, these private
+ * structures are the __DRIdrawablePrivateRec, __DRIcontextPrivateRec,
+ * __DRIscreenPrivateRec, and __DRIvisualPrivateRec structures defined
+ * in dri_util.h. We allocate and attach those structs here in
+ * this file.
+ */
+
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <assert.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <X11/Xlibint.h>
+#include <Xext.h>
+#include <extutil.h>
+#include <stdio.h>
+#include "glxclient.h"
+#include "xf86dri.h"
+#include "sarea.h"
+#include "dri_util.h"
+
+
+/* forward declarations */
+static void *driCreateDrawable(Display *dpy, int scrn, GLXDrawable draw,
+ GLboolean isPixmap,
+ VisualID vid, __DRIdrawable *pdraw);
+
+static void driDestroyDrawable(Display *dpy, void *drawablePrivate);
+
+
+
+
+static Bool driFeatureOn(const char *name)
+{
+ char *env = getenv(name);
+
+ if (!env) return GL_FALSE;
+ if (!strcasecmp(env, "enable")) return GL_TRUE;
+ if (!strcasecmp(env, "1")) return GL_TRUE;
+ if (!strcasecmp(env, "on")) return GL_TRUE;
+ if (!strcasecmp(env, "true")) return GL_TRUE;
+ if (!strcasecmp(env, "t")) return GL_TRUE;
+ if (!strcasecmp(env, "yes")) return GL_TRUE;
+ if (!strcasecmp(env, "y")) return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+
+/*
+** Print message to stderr if LIBGL_DEBUG env var is set.
+*/
+void
+__driUtilMessage(const char *f, ...)
+{
+ va_list args;
+
+ if (getenv("LIBGL_DEBUG")) {
+ fprintf(stderr, "libGL error: \n");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ fprintf(stderr, "\n");
+ }
+}
+
+
+/*****************************************************************/
+
+/*
+ * Return pointer to the __GLXvisualConfig specified by dpy, scrn and vid.
+ * Return NULL if not found.
+ */
+static __GLXvisualConfig *
+__driFindGlxConfig(Display *dpy, int scrn, VisualID vid)
+{
+ __GLXdisplayPrivate *priv;
+ __GLXscreenConfigs *glxScrnConfigs;
+ __GLXvisualConfig *glxConfigs;
+ int numConfigs, i;
+
+ priv = __glXInitialize(dpy);
+ assert(priv);
+
+ glxScrnConfigs = priv->screenConfigs;
+ assert(glxScrnConfigs);
+
+ numConfigs = glxScrnConfigs[scrn].numConfigs;
+ glxConfigs = glxScrnConfigs[scrn].configs;
+
+ for (i = 0; i < numConfigs; i++) {
+ if (glxConfigs[i].vid == vid) {
+ return glxConfigs +i;
+ }
+ }
+ return NULL;
+}
+
+
+/* This function comes from programs/Xserver/GL/glx/glxcmds.c
+ */
+static void
+__glXFormatGLModes(__GLcontextModes *modes, const __GLXvisualConfig *config)
+{
+ /*__glXMemset(modes, 0, sizeof(__GLcontextModes));*/
+ memset(modes, 0, sizeof(__GLcontextModes));
+
+ modes->rgbMode = (config->rgba != 0);
+ modes->colorIndexMode = !(modes->rgbMode);
+ modes->doubleBufferMode = (config->doubleBuffer != 0);
+ modes->stereoMode = (config->stereo != 0);
+
+ modes->haveAccumBuffer = ((config->accumRedSize +
+ config->accumGreenSize +
+ config->accumBlueSize +
+ config->accumAlphaSize) > 0);
+ modes->haveDepthBuffer = (config->depthSize > 0);
+ modes->haveStencilBuffer = (config->stencilSize > 0);
+
+ modes->redBits = config->redSize;
+ modes->greenBits = config->greenSize;
+ modes->blueBits = config->blueSize;
+ modes->alphaBits = config->alphaSize;
+ modes->redMask = config->redMask;
+ modes->greenMask = config->greenMask;
+ modes->blueMask = config->blueMask;
+ modes->alphaMask = config->alphaMask;
+ modes->rgbBits = config->bufferSize;
+ modes->indexBits = config->bufferSize;
+
+ modes->accumRedBits = config->accumRedSize;
+ modes->accumGreenBits = config->accumGreenSize;
+ modes->accumBlueBits = config->accumBlueSize;
+ modes->accumAlphaBits = config->accumAlphaSize;
+ modes->depthBits = config->depthSize;
+ modes->stencilBits = config->stencilSize;
+
+ modes->numAuxBuffers = 0; /* XXX: should be picked up from the visual */
+
+ modes->level = config->level;
+}
+
+
+/*****************************************************************/
+
+/* Maintain a list of drawables */
+
+static Bool __driAddDrawable(void *drawHash, __DRIdrawable *pdraw)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+ if (drmHashInsert(drawHash, pdp->draw, pdraw))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+static __DRIdrawable *__driFindDrawable(void *drawHash, GLXDrawable draw)
+{
+ int retcode;
+ __DRIdrawable *pdraw;
+
+ retcode = drmHashLookup(drawHash, draw, (void **)&pdraw);
+ if (retcode)
+ return NULL;
+
+ return pdraw;
+}
+
+static void __driRemoveDrawable(void *drawHash, __DRIdrawable *pdraw)
+{
+ int retcode;
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+ retcode = drmHashLookup(drawHash, pdp->draw, (void **)&pdraw);
+ if (!retcode) { /* Found */
+ drmHashDelete(drawHash, pdp->draw);
+ }
+}
+
+static Bool __driWindowExistsFlag;
+
+static int __driWindowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+ if (xerr->error_code == BadWindow) {
+ __driWindowExistsFlag = GL_FALSE;
+ }
+ return 0;
+}
+
+static Bool __driWindowExists(Display *dpy, GLXDrawable draw)
+{
+ XWindowAttributes xwa;
+ int (*oldXErrorHandler)(Display *, XErrorEvent *);
+
+ __driWindowExistsFlag = GL_TRUE;
+ oldXErrorHandler = XSetErrorHandler(__driWindowExistsErrorHandler);
+ XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+ XSetErrorHandler(oldXErrorHandler);
+ return __driWindowExistsFlag;
+}
+
+static void __driGarbageCollectDrawables(void *drawHash)
+{
+ GLXDrawable draw;
+ __DRIdrawable *pdraw;
+ Display *dpy;
+
+ if (drmHashFirst(drawHash, &draw, (void **)&pdraw)) {
+ do {
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+ dpy = pdp->driScreenPriv->display;
+ XSync(dpy, GL_FALSE);
+ if (!__driWindowExists(dpy, draw)) {
+ /* Destroy the local drawable data in the hash table, if the
+ drawable no longer exists in the Xserver */
+ __driRemoveDrawable(drawHash, pdraw);
+ (*pdraw->destroyDrawable)(dpy, pdraw->private);
+ Xfree(pdraw);
+ }
+ } while (drmHashNext(drawHash, &draw, (void **)&pdraw));
+ }
+}
+
+/*****************************************************************/
+
+static Bool driUnbindContext(Display *dpy, int scrn,
+ GLXDrawable draw, GLXContext gc,
+ int will_rebind)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIdrawable *pdraw;
+ __DRIcontextPrivate *pcp;
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driUnbindContext.
+ */
+
+ if (gc == NULL || draw == None) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ pcp = (__DRIcontextPrivate *)gc->driContext.private;
+
+ pdraw = __driFindDrawable(psp->drawHash, draw);
+ if (!pdraw) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+ pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+ /* Don't leave fullscreen mode if the
+ drawable will be rebound in the next
+ step -- this avoids a protocol
+ request. */
+ if (!will_rebind && psp->fullscreen) {
+ psp->DriverAPI.CloseFullScreen(pcp);
+ XF86DRICloseFullScreen(dpy, scrn, draw);
+ psp->fullscreen = NULL;
+ }
+
+ /* Let driver unbind drawable from context */
+ (*psp->DriverAPI.UnbindContext)(pcp);
+
+ if (pdp->refcount == 0) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ } else if (--pdp->refcount == 0) {
+#if 0
+ /*
+ ** NOT_DONE: When a drawable is unbound from one direct
+ ** rendering context and then bound to another, we do not want
+ ** to destroy the drawable data structure each time only to
+ ** recreate it immediatly afterwards when binding to the next
+ ** context. This also causes conflicts with caching of the
+ ** drawable stamp.
+ **
+ ** In addition, we don't destroy the drawable here since Mesa
+ ** keeps private data internally (e.g., software accumulation
+ ** buffers) that should not be destroyed unless the client
+ ** explicitly requests that the window be destroyed.
+ **
+ ** When GLX 1.3 is integrated, the create and destroy drawable
+ ** functions will have user level counterparts and the memory
+ ** will be able to be recovered.
+ **
+ ** Below is an example of what needs to go into the destroy
+ ** drawable routine to support GLX 1.3.
+ */
+ __driRemoveDrawable(psp->drawHash, pdraw);
+ (*pdraw->destroyDrawable)(dpy, pdraw->private);
+ Xfree(pdraw);
+#endif
+ }
+
+ /* XXX this is disabled so that if we call SwapBuffers on an unbound
+ * window we can determine the last context bound to the window and
+ * use that context's lock. (BrianP, 2-Dec-2000)
+ */
+#if 0
+ /* Unbind the drawable */
+ pcp->driDrawablePriv = NULL;
+ pdp->driContextPriv = &psp->dummyContextPriv;
+#endif
+
+ return GL_TRUE;
+}
+
+
+/*
+ * This function takes both a read buffer and a draw buffer.
+ * This is needed for glXMakeCurrentReadSGI() or GLX 1.3's
+ * glxMakeContextCurrent() function.
+ */
+static Bool driBindContext2(Display *dpy, int scrn,
+ GLXDrawable draw, GLXDrawable read,
+ GLXContext gc)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIdrawable *pdraw;
+ __DRIdrawablePrivate *pdp;
+ __DRIdrawable *pread;
+ __DRIdrawablePrivate *prp;
+ __DRIscreenPrivate *psp;
+ __DRIcontextPrivate *pcp;
+ static Bool envchecked = False;
+ static Bool checkfullscreen = False;
+
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driBindContext.
+ */
+
+ if (gc == NULL || draw == None || read == None) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ /* Find the _DRIdrawable which corresponds to the writing GLXDrawable */
+ pdraw = __driFindDrawable(psp->drawHash, draw);
+ if (!pdraw) {
+ /* Allocate a new drawable */
+ pdraw = (__DRIdrawable *)Xmalloc(sizeof(__DRIdrawable));
+ if (!pdraw) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ /* Create a new drawable */
+ pdraw->private = driCreateDrawable(dpy, scrn, draw, GL_FALSE,
+ gc->vid, pdraw);
+ if (!pdraw->private) {
+ /* ERROR!!! */
+ Xfree(pdraw);
+ return GL_FALSE;
+ }
+
+ /* Add pdraw to drawable list */
+ if (!__driAddDrawable(psp->drawHash, pdraw)) {
+ /* ERROR!!! */
+ (*pdraw->destroyDrawable)(dpy, pdraw->private);
+ Xfree(pdraw);
+ return GL_FALSE;
+ }
+ }
+ pdp = (__DRIdrawablePrivate *) pdraw->private;
+
+ /* Find the _DRIdrawable which corresponds to the reading GLXDrawable */
+ if (read == draw) {
+ /* read buffer == draw buffer */
+ prp = pdp;
+ }
+ else {
+ pread = __driFindDrawable(psp->drawHash, read);
+ if (!pread) {
+ /* Allocate a new drawable */
+ pread = (__DRIdrawable *)Xmalloc(sizeof(__DRIdrawable));
+ if (!pread) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ /* Create a new drawable */
+ pread->private = driCreateDrawable(dpy, scrn, read, GL_FALSE,
+ gc->vid, pread);
+ if (!pread->private) {
+ /* ERROR!!! */
+ Xfree(pread);
+ return GL_FALSE;
+ }
+
+ /* Add pread to drawable list */
+ if (!__driAddDrawable(psp->drawHash, pread)) {
+ /* ERROR!!! */
+ (*pread->destroyDrawable)(dpy, pread->private);
+ Xfree(pread);
+ return GL_FALSE;
+ }
+ }
+ prp = (__DRIdrawablePrivate *) pread->private;
+ }
+
+ /* Bind the drawable to the context */
+ pcp = (__DRIcontextPrivate *)gc->driContext.private;
+ pcp->driDrawablePriv = pdp;
+ pdp->driContextPriv = pcp;
+ pdp->refcount++;
+
+ /*
+ ** Now that we have a context associated with this drawable, we can
+ ** initialize the drawable information if has not been done before.
+ ** Also, since we need it when LIBGL_DRI_FULLSCREEN, pick up any changes
+ ** that are outstanding.
+ */
+ if (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp) {
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+ __driUtilUpdateDrawableInfo(pdp);
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+ }
+
+ /* Call device-specific MakeCurrent */
+ (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp);
+
+ /* Check for the potential to enter an automatic full-screen mode.
+ This may need to be moved up. */
+ if (!envchecked) {
+ checkfullscreen = driFeatureOn("LIBGL_DRI_AUTOFULLSCREEN");
+ envchecked = GL_TRUE;
+ }
+ if (checkfullscreen && pdp->numClipRects == 1) {
+ /* If there is valid information in the SAREA, we can use it to
+ avoid a protocol request. The only time when the SAREA
+ information won't be valid will be initially, so in the worst
+ case, we'll make one protocol request that we could have
+ avoided. */
+ int try = 1;
+ int clw = pdp->pClipRects[0].x2 - pdp->pClipRects[0].x1;
+ int clh = pdp->pClipRects[0].y2 - pdp->pClipRects[0].y1;
+
+#if 0
+ /* Useful client-side debugging message */
+ fprintf(stderr,
+ "********************************************\n"
+ "********************************************\n"
+ "********************************************\n"
+ "%d @ %d,%d,%d,%d\n"
+ "frame %d,%d,%d,%d\n"
+ "win %d,%d,%d,%d\n"
+ "fs = %p pdp = %p sarea = %d\n"
+ "********************************************\n"
+ "********************************************\n"
+ "********************************************\n",
+ pdp->numClipRects,
+ pdp->pClipRects[0].x1,
+ pdp->pClipRects[0].y1,
+ pdp->pClipRects[0].x2,
+ pdp->pClipRects[0].y2,
+ psp->pSAREA->frame.x,
+ psp->pSAREA->frame.y,
+ psp->pSAREA->frame.width,
+ psp->pSAREA->frame.height,
+ pdp->x, pdp->y, pdp->w, pdp->h,
+ psp->fullscreen, pdp, psp->pSAREA->frame.fullscreen);
+#endif
+
+
+ if (pdp->x != pdp->pClipRects[0].x1
+ || pdp->y != pdp->pClipRects[0].y1
+ || pdp->w != clw
+ || pdp->h != clh) try = 0;
+
+ if (try && psp->pSAREA->frame.width && psp->pSAREA->frame.height) {
+ if (pdp->x != psp->pSAREA->frame.x
+ || pdp->y != psp->pSAREA->frame.y
+ || pdp->w != psp->pSAREA->frame.width
+ || pdp->h != psp->pSAREA->frame.height) try = 0;
+ }
+
+ if (try) {
+ if (psp->fullscreen && !psp->pSAREA->frame.fullscreen) {
+ /* Server has closed fullscreen mode */
+ __driUtilMessage("server closed fullscreen mode\n");
+ psp->fullscreen = NULL;
+ }
+ if (XF86DRIOpenFullScreen(dpy, scrn, draw)) {
+ psp->fullscreen = pdp;
+ psp->DriverAPI.OpenFullScreen(pcp);
+ }
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+/*
+ * Simply call bind with the same GLXDrawable for the read and draw buffers.
+ */
+static Bool driBindContext(Display *dpy, int scrn,
+ GLXDrawable draw, GLXContext gc)
+{
+ return driBindContext2(dpy, scrn, draw, draw, gc);
+}
+
+
+/*****************************************************************/
+
+/*
+ * This function basically updates the __DRIdrawablePrivate struct's
+ * cliprect information by calling XF86DRIGetDrawableInfo(). This is
+ * usually called by the DRI_VALIDATE_DRAWABLE_INFO macro which
+ * compares the __DRIdrwablePrivate pStamp and lastStamp values. If
+ * the values are different that means we have to update the clipping
+ * info.
+ */
+void
+__driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
+{
+ __DRIscreenPrivate *psp;
+ __DRIcontextPrivate *pcp = pdp->driContextPriv;
+
+ if (!pcp || (pdp != pcp->driDrawablePriv)) {
+ /* ERROR!!! */
+ return;
+ }
+
+ psp = pdp->driScreenPriv;
+ if (!psp) {
+ /* ERROR!!! */
+ return;
+ }
+
+ if (pdp->pClipRects) {
+ Xfree(pdp->pClipRects);
+ }
+
+ if (pdp->pBackClipRects) {
+ Xfree(pdp->pBackClipRects);
+ }
+
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+
+ if (!XF86DRIGetDrawableInfo(pdp->display, pdp->screen, pdp->draw,
+ &pdp->index, &pdp->lastStamp,
+ &pdp->x, &pdp->y, &pdp->w, &pdp->h,
+ &pdp->numClipRects, &pdp->pClipRects,
+ &pdp->backX,
+ &pdp->backY,
+ &pdp->numBackClipRects,
+ &pdp->pBackClipRects
+ )) {
+ pdp->numClipRects = 0;
+ pdp->pClipRects = NULL;
+ pdp->numBackClipRects = 0;
+ pdp->pBackClipRects = 0;
+ /* ERROR!!! */
+ }
+
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+
+ pdp->pStamp = &(psp->pSAREA->drawableTable[pdp->index].stamp);
+}
+
+/*****************************************************************/
+
+/*
+ * Called directly from glXSwapBuffers().
+ */
+static void driSwapBuffers( Display *dpy, void *drawablePrivate )
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ dPriv->swapBuffers(dPriv);
+ (void) dpy;
+}
+
+
+/*
+ * This is called via __DRIscreenRec's createDrawable pointer.
+ * libGL doesn't use it at this time. See comments in glxclient.h.
+ */
+static void *driCreateDrawable_dummy(Display *dpy, int scrn,
+ GLXDrawable draw,
+ VisualID vid, __DRIdrawable *pdraw)
+{
+ return driCreateDrawable(dpy, scrn, draw, GL_FALSE, vid, pdraw);
+}
+
+
+
+static void *driCreateDrawable(Display *dpy, int scrn, GLXDrawable draw,
+ GLboolean isPixmap,
+ VisualID vid, __DRIdrawable *pdraw)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+ __GLXvisualConfig *config;
+ __GLcontextModes modes;
+
+ pdp = (__DRIdrawablePrivate *)Xmalloc(sizeof(__DRIdrawablePrivate));
+ if (!pdp) {
+ return NULL;
+ }
+
+ if (!XF86DRICreateDrawable(dpy, scrn, draw, &pdp->hHWDrawable)) {
+ Xfree(pdp);
+ return NULL;
+ }
+
+ pdp->draw = draw;
+ pdp->refcount = 0;
+ pdp->pStamp = NULL;
+ pdp->lastStamp = 0;
+ pdp->index = 0;
+ pdp->x = 0;
+ pdp->y = 0;
+ pdp->w = 0;
+ pdp->h = 0;
+ pdp->numClipRects = 0;
+ pdp->numBackClipRects = 0;
+ pdp->pClipRects = NULL;
+ pdp->pBackClipRects = NULL;
+ pdp->display = dpy;
+ pdp->screen = scrn;
+
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, scrn))) {
+ (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+ Xfree(pdp);
+ return NULL;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+ Xfree(pdp);
+ return NULL;
+ }
+ pdp->driScreenPriv = psp;
+ pdp->driContextPriv = &psp->dummyContextPriv;
+
+ config = __driFindGlxConfig(dpy, scrn, vid);
+ if (!config)
+ return NULL;
+
+ /* convert GLXvisualConfig struct to GLcontextModes struct */
+ __glXFormatGLModes(&modes, config);
+
+ if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &modes, isPixmap)) {
+ (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+ Xfree(pdp);
+ return NULL;
+ }
+
+ pdraw->destroyDrawable = driDestroyDrawable;
+ pdraw->swapBuffers = driSwapBuffers; /* called by glXSwapBuffers() */
+ pdp->swapBuffers = psp->DriverAPI.SwapBuffers;
+
+ return (void *) pdp;
+}
+
+static __DRIdrawable *driGetDrawable(Display *dpy, GLXDrawable draw,
+ void *screenPrivate)
+{
+ __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
+
+ /*
+ ** Make sure this routine returns NULL if the drawable is not bound
+ ** to a direct rendering context!
+ */
+ return __driFindDrawable(psp->drawHash, draw);
+}
+
+static void driDestroyDrawable(Display *dpy, void *drawablePrivate)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *) drawablePrivate;
+ __DRIscreenPrivate *psp = pdp->driScreenPriv;
+ int scrn = psp->myNum;
+
+ if (pdp) {
+ (*psp->DriverAPI.DestroyBuffer)(pdp);
+ if (__driWindowExists(dpy, pdp->draw))
+ (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw);
+ if (pdp->pClipRects)
+ Xfree(pdp->pClipRects);
+ Xfree(pdp);
+ }
+}
+
+/*****************************************************************/
+
+static void driDestroyContext(Display *dpy, int scrn, void *contextPrivate)
+{
+ __DRIcontextPrivate *pcp = (__DRIcontextPrivate *) contextPrivate;
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+
+ if (pcp) {
+ if ((pdp = pcp->driDrawablePriv)) {
+ /* Shut down fullscreen mode */
+ if ((psp = pdp->driScreenPriv) && psp->fullscreen) {
+ psp->DriverAPI.CloseFullScreen(pcp);
+ XF86DRICloseFullScreen(dpy, scrn, pdp->draw);
+ psp->fullscreen = NULL;
+ }
+ }
+ __driGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
+ (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);
+ (void)XF86DRIDestroyContext(dpy, scrn, pcp->contextID);
+ Xfree(pcp);
+ }
+}
+
+static void *driCreateContext(Display *dpy, XVisualInfo *vis,
+ void *sharedPrivate,
+ __DRIcontext *pctx)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIcontextPrivate *pcp;
+ __DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate;
+ __DRIscreenPrivate *psp;
+ __GLXvisualConfig *config;
+ __GLcontextModes modes;
+ void *shareCtx;
+
+ if (!(pDRIScreen = __glXFindDRIScreen(dpy, vis->screen))) {
+ /* ERROR!!! */
+ return NULL;
+ } else if (!(psp = (__DRIscreenPrivate *)pDRIScreen->private)) {
+ /* ERROR!!! */
+ return NULL;
+ }
+
+ if (!psp->dummyContextPriv.driScreenPriv) {
+ if (!XF86DRICreateContext(dpy, vis->screen, vis->visual,
+ &psp->dummyContextPriv.contextID,
+ &psp->dummyContextPriv.hHWContext)) {
+ return NULL;
+ }
+ psp->dummyContextPriv.driScreenPriv = psp;
+ psp->dummyContextPriv.driDrawablePriv = NULL;
+ psp->dummyContextPriv.driverPrivate = NULL;
+ /* No other fields should be used! */
+ }
+
+ /* Create the hash table */
+ if (!psp->drawHash) psp->drawHash = drmHashCreate();
+
+ pcp = (__DRIcontextPrivate *)Xmalloc(sizeof(__DRIcontextPrivate));
+ if (!pcp) {
+ return NULL;
+ }
+
+ pcp->display = dpy;
+ pcp->driScreenPriv = psp;
+ pcp->driDrawablePriv = NULL;
+
+ if (!XF86DRICreateContext(dpy, vis->screen, vis->visual,
+ &pcp->contextID, &pcp->hHWContext)) {
+ Xfree(pcp);
+ return NULL;
+ }
+
+ /* This is moved because the Xserver creates a global dummy context
+ * the first time XF86DRICreateContext is called.
+ */
+
+ if (!psp->dummyContextPriv.driScreenPriv) {
+#if 0
+ /* We no longer use this cause we have the shared dummyContext
+ * in the SAREA.
+ */
+ if (!XF86DRICreateContext(dpy, vis->screen, vis->visual,
+ &psp->dummyContextPriv.contextID,
+ &psp->dummyContextPriv.hHWContext)) {
+ return NULL;
+ }
+#endif
+ psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context;
+ psp->dummyContextPriv.driScreenPriv = psp;
+ psp->dummyContextPriv.driDrawablePriv = NULL;
+ psp->dummyContextPriv.driverPrivate = NULL;
+ /* No other fields should be used! */
+ }
+
+ /* Setup a __GLcontextModes struct corresponding to vis->visualid
+ * and create the rendering context.
+ */
+ config = __driFindGlxConfig(dpy, vis->screen, vis->visualid);
+ if (!config)
+ return NULL;
+
+ __glXFormatGLModes(&modes, config);
+ shareCtx = pshare ? pshare->driverPrivate : NULL;
+ if (!(*psp->DriverAPI.CreateContext)(&modes, pcp, shareCtx)) {
+ (void)XF86DRIDestroyContext(dpy, vis->screen, pcp->contextID);
+ Xfree(pcp);
+ return NULL;
+ }
+
+ pctx->destroyContext = driDestroyContext;
+ pctx->bindContext = driBindContext;
+ pctx->unbindContext = driUnbindContext;
+
+ __driGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
+
+ return pcp;
+}
+
+/*****************************************************************/
+
+static void driDestroyScreen(Display *dpy, int scrn, void *screenPrivate)
+{
+ __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
+
+ if (psp) {
+#if 0
+ /*
+ ** NOT_DONE: For the same reason as that listed below, we cannot
+ ** call the X server here to destroy the dummy context.
+ */
+ if (psp->dummyContextPriv.driScreenPriv) {
+ (void)XF86DRIDestroyContext(dpy, scrn,
+ psp->dummyContextPriv.contextID);
+ }
+#endif
+ if (psp->DriverAPI.DestroyScreen)
+ (*psp->DriverAPI.DestroyScreen)(psp);
+
+ (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
+ (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
+ Xfree(psp->pDevPriv);
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+
+#if 0
+ /*
+ ** NOT_DONE: Normally, we would call XF86DRICloseConnection()
+ ** here, but since this routine is called after the
+ ** XCloseDisplay() function has already shut down the connection
+ ** to the Display, there is no protocol stream open to the X
+ ** server anymore. Luckily, XF86DRICloseConnection() does not
+ ** really do anything (for now).
+ */
+ (void)XF86DRICloseConnection(dpy, scrn);
+#endif
+ }
+}
+
+
+__DRIscreenPrivate *
+__driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config,
+ const struct __DriverAPIRec *driverAPI)
+{
+ int directCapable;
+ __DRIscreenPrivate *psp;
+ drmHandle hFB, hSAREA;
+ char *BusID, *driverName;
+ drmMagic magic;
+
+ if (!XF86DRIQueryDirectRenderingCapable(dpy, scrn, &directCapable)) {
+ return NULL;
+ }
+
+ if (!directCapable) {
+ return NULL;
+ }
+
+ psp = (__DRIscreenPrivate *)Xmalloc(sizeof(__DRIscreenPrivate));
+ if (!psp) {
+ return NULL;
+ }
+
+ psp->display = dpy;
+ psp->myNum = scrn;
+
+ if (!XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
+ Xfree(psp);
+ return NULL;
+ }
+
+ /*
+ ** NOT_DONE: This is used by the X server to detect when the client
+ ** has died while holding the drawable lock. The client sets the
+ ** drawable lock to this value.
+ */
+ psp->drawLockID = 1;
+
+ psp->fd = drmOpen(NULL,BusID);
+ if (psp->fd < 0) {
+ fprintf(stderr, "libGL error: failed to open DRM: %s\n", strerror(-psp->fd));
+ fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
+ Xfree(BusID);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+ Xfree(BusID); /* No longer needed */
+
+ if (drmGetMagic(psp->fd, &magic)) {
+ fprintf(stderr, "libGL error: drmGetMagic failed\n");
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+
+ {
+ drmVersionPtr version = drmGetVersion(psp->fd);
+ if (version) {
+ psp->drmMajor = version->version_major;
+ psp->drmMinor = version->version_minor;
+ psp->drmPatch = version->version_patchlevel;
+ drmFreeVersion(version);
+ }
+ else {
+ psp->drmMajor = -1;
+ psp->drmMinor = -1;
+ psp->drmPatch = -1;
+ }
+ }
+
+ if (!XF86DRIAuthConnection(dpy, scrn, magic)) {
+ fprintf(stderr, "libGL error: XF86DRIAuthConnection failed\n");
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+
+ /*
+ * Get device name (like "tdfx") and the ddx version numbers.
+ * We'll check the version in each DRI driver's "createScreen"
+ * function.
+ */
+ if (!XF86DRIGetClientDriverName(dpy, scrn,
+ &psp->ddxMajor,
+ &psp->ddxMinor,
+ &psp->ddxPatch,
+ &driverName)) {
+ fprintf(stderr, "libGL error: XF86DRIGetClientDriverName failed\n");
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+
+ /*
+ * Get the DRI X extension version.
+ */
+ if (!XF86DRIQueryVersion(dpy,
+ &psp->driMajor,
+ &psp->driMinor,
+ &psp->driPatch)) {
+ fprintf(stderr, "libGL error: XF86DRIQueryVersion failed\n");
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+
+ /* install driver's callback functions */
+ memcpy(&psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec));
+
+ /*
+ * 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 (!XF86DRIGetDeviceInfo(dpy, scrn,
+ &hFB,
+ &psp->fbOrigin,
+ &psp->fbSize,
+ &psp->fbStride,
+ &psp->devPrivSize,
+ &psp->pDevPriv)) {
+ fprintf(stderr, "libGL error: XF86DRIGetDeviceInfo failed\n");
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+ psp->fbWidth = DisplayWidth(dpy, scrn);
+ psp->fbHeight = DisplayHeight(dpy, scrn);
+ psp->fbBPP = 32; /* NOT_DONE: Get this from X server */
+
+ /*
+ * Map the framebuffer region.
+ */
+ if (drmMap(psp->fd, hFB, psp->fbSize, (drmAddressPtr)&psp->pFB)) {
+ fprintf(stderr, "libGL error: drmMap of framebuffer failed\n");
+ Xfree(psp->pDevPriv);
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+
+ /*
+ * Map the SAREA region. Further mmap regions may be setup in
+ * each DRI driver's "createScreen" function.
+ */
+ if (drmMap(psp->fd, hSAREA, SAREA_MAX, (drmAddressPtr)&psp->pSAREA)) {
+ fprintf(stderr, "libGL error: drmMap of sarea failed\n");
+ (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
+ Xfree(psp->pDevPriv);
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+
+ /* Initialize the screen specific GLX driver */
+ if (psp->DriverAPI.InitDriver) {
+ if (!(*psp->DriverAPI.InitDriver)(psp)) {
+ fprintf(stderr, "libGL error: InitDriver failed\n");
+ (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
+ (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
+ Xfree(psp->pDevPriv);
+ (void)drmClose(psp->fd);
+ Xfree(psp);
+ (void)XF86DRICloseConnection(dpy, scrn);
+ return NULL;
+ }
+ }
+
+ /*
+ ** Do not init dummy context here; actual initialization will be
+ ** done when the first DRI context is created. Init screen priv ptr
+ ** to NULL to let CreateContext routine that it needs to be inited.
+ */
+ psp->dummyContextPriv.driScreenPriv = NULL;
+
+ /* Initialize the drawHash when the first context is created */
+ psp->drawHash = NULL;
+
+ psc->destroyScreen = driDestroyScreen;
+ psc->createContext = driCreateContext;
+ psc->createDrawable = driCreateDrawable_dummy;
+ psc->getDrawable = driGetDrawable;
+
+ return psp;
+}
+
+
+#endif
diff --git a/xc/lib/GL/dri/dri_util.h b/xc/lib/GL/dri/dri_util.h
new file mode 100644
index 000000000..b3073eaac
--- /dev/null
+++ b/xc/lib/GL/dri/dri_util.h
@@ -0,0 +1,373 @@
+/* $XFree86$ */
+/**************************************************************************
+
+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 PRECISION INSIGHT AND/OR ITS 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>
+ */
+
+/*
+ * This module acts as glue between GLX and the actual hardware driver.
+ * A DRI driver doesn't really _have_ to use any of this - it's optional.
+ * But, some useful stuff is done here that otherwise would have to be
+ * duplicated in most drivers.
+ *
+ * Basically, these utility functions take care of some of the dirty details
+ * of screen initialization, context creation, context binding, DRM setup,
+ * etc.
+ *
+ * These functions are compiled into each DRI driver so libGL.so knows
+ * nothing about them.
+ *
+ * Look for more comments in the dri_util.c file.
+ */
+
+
+
+#ifndef _DRI_UTIL_H_
+#define _DRI_UTIL_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+#define CAPI /* XXX this should be globally defined somewhere */
+
+#include "glxclient.h" /* for GLXDrawable */
+#include "xf86dri.h" /* for XF86DRIClipRectPtr */
+#include "sarea.h" /* for XF86DRISAREAPtr */
+#include "GL/internal/glcore.h" /* for __GLcontextModes */
+
+
+typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
+typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
+typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
+typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
+
+
+#define DRI_VALIDATE_DRAWABLE_INFO_ONCE(pDrawPriv) \
+ do { \
+ if (*(pDrawPriv->pStamp) != pDrawPriv->lastStamp) { \
+ __driUtilUpdateDrawableInfo(pDrawPriv); \
+ } \
+ } while (0)
+
+
+#define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp) \
+do { \
+ while (*(pdp->pStamp) != pdp->lastStamp) { \
+ DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, \
+ pdp->driContextPriv->hHWContext); \
+ \
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ \
+ DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, \
+ pdp->driContextPriv->hHWContext); \
+ } \
+} while (0)
+
+
+/* Each DRI driver must have one of these structs with all the pointers
+ * set to appropriate functions within the driver.
+ * When glXCreateContext is called, for example, it'll call a helper
+ * function dri_util.c which in turn will jump through the CreateContext
+ * pointer in this structure.
+ */
+struct __DriverAPIRec {
+ GLboolean (*InitDriver)(__DRIscreenPrivate *driScrnPriv);
+ void (*DestroyScreen)(__DRIscreenPrivate *driScrnPriv);
+ GLboolean (*CreateContext)(const __GLcontextModes *glVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+ void (*DestroyContext)(__DRIcontextPrivate *driContextPriv);
+ GLboolean (*CreateBuffer)(__DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *glVis,
+ GLboolean pixmapBuffer);
+ void (*DestroyBuffer)(__DRIdrawablePrivate *driDrawPriv);
+ void (*SwapBuffers)(__DRIdrawablePrivate *driDrawPriv);
+ GLboolean (*MakeCurrent)(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+ GLboolean (*UnbindContext)(__DRIcontextPrivate *driContextPriv);
+ GLboolean (*OpenFullScreen)(__DRIcontextPrivate *driContextPriv);
+ GLboolean (*CloseFullScreen)(__DRIcontextPrivate *driContextPriv);
+};
+
+
+struct __DRIdrawablePrivateRec {
+ /*
+ ** Kernel drawable handle (not currently used).
+ */
+ drmDrawable hHWDrawable;
+
+ /*
+ ** Driver's private drawable information. This structure is opaque.
+ */
+ void *driverPrivate;
+
+ /*
+ ** X's drawable ID associated with this private drawable.
+ */
+ GLXDrawable draw;
+
+ /*
+ ** Reference count for number of context's currently bound to this
+ ** drawable. Once the refcount reaches 0, the drawable can be
+ ** destroyed. This behavior will change with GLX 1.3.
+ */
+ int refcount;
+
+ /*
+ ** Index of this drawable's information in the SAREA.
+ */
+ unsigned int index;
+
+ /*
+ ** Pointer to the "drawable has changed ID" stamp in the SAREA.
+ */
+ unsigned int *pStamp;
+
+ /*
+ ** Last value of the stamp. If this differs from the value stored
+ ** at *pStamp, then the drawable information has been modified by
+ ** the X server, and the drawable information (below) should be
+ ** retrieved from the X server.
+ */
+ unsigned int lastStamp;
+
+ /*
+ ** Drawable information used in software fallbacks.
+ */
+ int x;
+ int y;
+ int w;
+ int h;
+ int numClipRects;
+ XF86DRIClipRectPtr pClipRects;
+
+ /*
+ ** Information about the back and depthbuffer where different
+ ** from above.
+ */
+ int backX;
+ int backY;
+ int backClipRectType;
+ int numBackClipRects;
+ XF86DRIClipRectPtr pBackClipRects;
+
+ /*
+ ** Pointer to context to which this drawable is currently bound.
+ */
+ __DRIcontextPrivate *driContextPriv;
+
+ /*
+ ** Pointer to screen on which this drawable was created.
+ */
+ __DRIscreenPrivate *driScreenPriv;
+
+ /*
+ ** Basically just need these for when the locking code needs to call
+ ** __driUtilUpdateDrawableInfo() which calls XF86DRIGetDrawableInfo().
+ */
+ Display *display;
+ int screen;
+
+ /*
+ ** Called via glXSwapBuffers().
+ */
+ void (*swapBuffers)( __DRIdrawablePrivate *dPriv );
+};
+
+struct __DRIcontextPrivateRec {
+ /*
+ ** Kernel context handle used to access the device lock.
+ */
+ XID contextID;
+
+ /*
+ ** Kernel context handle used to access the device lock.
+ */
+ drmContext hHWContext;
+
+ /*
+ ** Device driver's private context data. This structure is opaque.
+ */
+ void *driverPrivate;
+
+ /*
+ ** This context's display pointer.
+ */
+ Display *display;
+
+ /*
+ ** Pointer to drawable currently bound to this context.
+ */
+ __DRIdrawablePrivate *driDrawablePriv;
+
+ /*
+ ** Pointer to screen on which this context was created.
+ */
+ __DRIscreenPrivate *driScreenPriv;
+};
+
+struct __DRIscreenPrivateRec {
+ /*
+ ** Display for this screen
+ */
+ Display *display;
+
+ /*
+ ** Current screen's number
+ */
+ int myNum;
+
+ /*
+ ** Callback functions into the hardware-specific DRI driver code.
+ */
+ struct __DriverAPIRec DriverAPI;
+
+ /*
+ ** DDX / 2D driver version information.
+ */
+ int ddxMajor;
+ int ddxMinor;
+ int ddxPatch;
+
+ /*
+ ** DRI X extension version information.
+ */
+ int driMajor;
+ int driMinor;
+ int driPatch;
+
+ /*
+ ** DRM (kernel module) version information.
+ */
+ int drmMajor;
+ int drmMinor;
+ int drmPatch;
+
+ /*
+ ** ID used when the client sets the drawable lock. The X server
+ ** uses this value to detect if the client has died while holding
+ ** the drawable lock.
+ */
+ int drawLockID;
+
+ /*
+ ** File descriptor returned when the kernel device driver is opened.
+ ** It is used to:
+ ** - authenticate client to kernel
+ ** - map the frame buffer, SAREA, etc.
+ ** - close the kernel device driver
+ */
+ int fd;
+
+ /*
+ ** SAREA pointer used to access:
+ ** - the device lock
+ ** - the device-independent per-drawable and per-context(?) information
+ */
+ XF86DRISAREAPtr pSAREA;
+
+ /*
+ ** Direct frame buffer access information used for software
+ ** fallbacks.
+ */
+ unsigned char *pFB;
+ int fbSize;
+ int fbOrigin;
+ int fbStride;
+ int fbWidth;
+ int fbHeight;
+ int fbBPP;
+
+ /*
+ ** Device-dependent private information (stored in the SAREA). This
+ ** data is accessed by the client driver only.
+ */
+ void *pDevPriv;
+ int devPrivSize;
+
+ /*
+ ** Dummy context to which drawables are bound when not bound to any
+ ** other context. A dummy hHWContext is created for this context,
+ ** and is used by the GL core when a HW lock is required but the
+ ** drawable is not currently bound (e.g., potentially during a
+ ** SwapBuffers request). The dummy context is created when the
+ ** first "real" context is created on this screen.
+ */
+ __DRIcontextPrivate dummyContextPriv;
+
+ /*
+ ** Hash table to hold the drawable information for this screen.
+ */
+ void *drawHash;
+
+ /*
+ ** Device-dependent private information (not stored in the SAREA).
+ ** This pointer is never touched by the DRI layer.
+ */
+ void *private;
+
+ /* If we're in full screen mode (via DRIOpenFullScreen), this points
+ to the drawable that was bound. Otherwise, this is NULL. */
+ __DRIdrawablePrivate *fullscreen;
+};
+
+
+
+extern void
+__driUtilMessage(const char *f, ...);
+
+
+extern void
+__driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp);
+
+
+extern __DRIscreenPrivate *
+__driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config,
+ const struct __DriverAPIRec *driverAPI);
+
+/* This must be implemented in each driver */
+extern void *
+__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config);
+
+
+/* This is optionally implemented in each driver */
+extern void
+__driRegisterExtensions( void );
+
+
+#endif /* GLX_DIRECT_RENDERING */
+
+#endif /* _DRI_UTIL_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
index 4c7c38978..6e68b6dd2 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
@@ -3,7 +3,6 @@
#ifndef _FFB_CONTEXT_H
#define _FFB_CONTEXT_H
-#include <X11/Xlibint.h>
#include "dri_util.h"
#include "mtypes.h"
@@ -269,7 +268,6 @@ do { if ((STATE_MASK) & ~((FMESA)->state_dirty)) { \
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
- Display *display;
unsigned int clear_pixel;
unsigned int clear_depth;
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
index e14b6d443..396512143 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
@@ -26,10 +26,6 @@
*/
#include "mtypes.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
#include "mm.h"
#include "ffb_dd.h"
#include "ffb_span.h"
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
index e82c9ab51..da1de18f3 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
@@ -26,10 +26,6 @@
*/
#include "mtypes.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
#include "mm.h"
#include "ffb_dd.h"
#include "ffb_span.h"
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
index a92c69d09..ee956d371 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
@@ -27,20 +27,13 @@
#include "mtypes.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "mm.h"
#include "ffb_dd.h"
-#include "ffb_span.h"
-#include "ffb_depth.h"
#include "ffb_context.h"
#include "ffb_vb.h"
-#include "ffb_lines.h"
#include "ffb_points.h"
#include "ffb_tris.h"
#include "ffb_lock.h"
-#include "extensions.h"
+
#undef FFB_POINT_TRACE
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
index ed4f3b267..6f33a35d2 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
@@ -27,9 +27,6 @@
#include "mtypes.h"
-#include <stdio.h>
-#include <stdlib.h>
-
#include "mm.h"
#include "ffb_dd.h"
#include "ffb_span.h"
@@ -37,8 +34,6 @@
#include "ffb_context.h"
#include "ffb_vb.h"
#include "ffb_tris.h"
-#include "ffb_lines.h"
-#include "ffb_points.h"
#include "ffb_state.h"
#include "ffb_lock.h"
#include "extensions.h"
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
index 2d90fd1e3..d0d3c3b9d 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
@@ -25,9 +25,6 @@
* David S. Miller <davem@redhat.com>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "glheader.h"
#include "mtypes.h"
#include "macros.h"
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
index dfea68f4d..eff0d5d9f 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
@@ -27,9 +27,6 @@
#ifdef GLX_DIRECT_RENDERING
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
#include "ffb_xmesa.h"
#include "context.h"
#include "matrix.h"
@@ -43,9 +40,6 @@
#include "tnl/t_pipeline.h"
#include "array_cache/acache.h"
-
-#include "xf86dri.h"
-
#include "ffb_context.h"
#include "ffb_dd.h"
#include "ffb_span.h"
@@ -176,7 +170,7 @@ static const struct gl_pipeline_stage *ffb_pipeline[] = {
/* Create and initialize the Mesa and driver specific context data */
static GLboolean
-ffbCreateContext(Display *dpy, const __GLcontextModes *mesaVis,
+ffbCreateContext(const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
@@ -208,7 +202,6 @@ ffbCreateContext(Display *dpy, const __GLcontextModes *mesaVis,
ffbScreen = (ffbScreenPrivate *) sPriv->private;
/* Dri stuff. */
- fmesa->display = dpy;
fmesa->hHWContext = driContextPriv->hHWContext;
fmesa->driFd = sPriv->fd;
fmesa->driHwLock = &sPriv->pSAREA->lock;
@@ -315,8 +308,7 @@ ffbDestroyContext(__DRIcontextPrivate *driContextPriv)
/* Create and initialize the Mesa and driver specific pixmap buffer data */
static GLboolean
-ffbCreateBuffer(Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
@@ -346,9 +338,8 @@ ffbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
#define USE_FAST_SWAP
static void
-ffbSwapBuffers(Display *dpy, void *drawablePrivate)
+ffbSwapBuffers( __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
ffbContextPtr fmesa = (ffbContextPtr) dPriv->driContextPriv->driverPrivate;
unsigned int fbc, wid, wid_reg_val, dac_db_bit;
unsigned int shadow_dac_addr, active_dac_addr;
@@ -557,7 +548,7 @@ void ffbXMesaUpdateState(ffbContextPtr fmesa)
__DRIscreenPrivate *sPriv = fmesa->driScreen;
int stamp = dPriv->lastStamp;
- DRI_VALIDATE_DRAWABLE_INFO(fmesa->display, sPriv, dPriv);
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
if (dPriv->lastStamp != stamp) {
GLcontext *ctx = fmesa->glCtx;
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_context.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.c
index ce34acb44..f7db2adea 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_context.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.c
@@ -65,7 +65,7 @@ static const struct gl_pipeline_stage *gamma_pipeline[] = {
0,
};
-GLboolean gammaCreateContext( Display *dpy, const __GLcontextModes *glVisual,
+GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
@@ -91,8 +91,6 @@ GLboolean gammaCreateContext( Display *dpy, const __GLcontextModes *glVisual,
return GL_FALSE;
}
- gmesa->display = dpy;
-
gmesa->driContext = driContextPriv;
gmesa->driScreen = sPriv;
gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_context.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.h
index 2b7032b02..7f29e8186 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_context.h
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.h
@@ -58,8 +58,7 @@ typedef union {
extern void gammaDDUpdateHWState(GLcontext *ctx);
extern gammaScreenPtr gammaCreateScreen(__DRIscreenPrivate *sPriv);
extern void gammaDestroyScreen(__DRIscreenPrivate *sPriv);
-extern GLboolean gammaCreateContext( Display *dpy,
- const __GLcontextModes *glVisual,
+extern GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate);
@@ -249,8 +248,6 @@ struct gamma_context {
/* Mirrors of some DRI state
*/
- Display *display; /* X server display */
-
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c
index 4a7499579..12a48ee1f 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c
@@ -30,7 +30,7 @@ void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
- DRI_VALIDATE_DRAWABLE_INFO( gmesa->display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
if ( gmesa->lastStamp != dPriv->lastStamp ) {
gmesa->lastStamp = dPriv->lastStamp;
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h
index 2ef58c63b..bf9cf5f11 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h
@@ -246,15 +246,15 @@ do { \
} while (0)
#ifdef DO_VALIDATE
-#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp) \
+#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp) \
do { \
- __DRIscreenPrivate *psp = gcp->driScreen; \
- __DRIdrawablePrivate *pdp = gcp->driDrawable; \
+ /*__DRIscreenPrivate *psp = gcp->driScreen;*/ \
+ __DRIdrawablePrivate *pdp = gcp->driDrawable; \
\
if (*(pdp->pStamp) != pdp->lastStamp) { \
int old_index = pdp->index; \
while (*(pdp->pStamp) != pdp->lastStamp) { \
- DRI_VALIDATE_DRAWABLE_INFO_ONCE(gcp->display, psp->myNum, pdp);\
+ DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
} \
if (pdp->index != old_index) { \
gcp->Window &= ~W_GIDMask; \
@@ -262,8 +262,8 @@ do { \
CHECK_WC_DMA_BUFFER(gcp, 1); \
WRITE(gcp->WCbuf, GLINTWindow, gcp->Window|(gcp->FrameCount<<9));\
} \
- \
- gammaUpdateViewportOffset( gcp->glCtx); \
+ \
+ gammaUpdateViewportOffset( gcp->glCtx); \
\
if (pdp->numClipRects == 1 && \
pdp->pClipRects->x1 == pdp->x && \
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c
index f4fd2bf0b..85cd1e516 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c
@@ -36,15 +36,12 @@ gammaScreenPtr gammaCreateScreen( __DRIscreenPrivate *sPriv )
int i;
#if 0
- /* Check the DRI version */
- {
- int major, minor, patch;
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 3 || minor != 1 || patch < 0 ) {
- __driUtilMessage( "r128 DRI driver expected DRI version 3.1.x but got version %d.%d.%d", major, minor, patch );
- return GL_FALSE;
- }
- }
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 3 || sPriv->driMinor != 1 ) {
+ __driUtilMessage( "Gamma DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return NULL;
}
/* Check that the DDX driver version is compatible */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c
index 7e5f13a6c..867cd678b 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c
@@ -24,7 +24,6 @@
* 3DLabs Gamma driver
*/
-#include <X11/Xlibint.h>
#include "gamma_context.h"
#include "gamma_macros.h"
#include "macros.h"
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c
index d37d4748f..bb0a07a42 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c
@@ -1,8 +1,5 @@
/* $XFree86$ */
-#include <stdlib.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "mtypes.h"
#include "imports.h"
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c
index 82d55ed07..482b91029 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c
@@ -1,8 +1,5 @@
/* $XFree86$ */
-#include <stdlib.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "macros.h"
#include "mtypes.h"
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c
index d0ed2e659..baba8369b 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c
@@ -1,8 +1,5 @@
/* $XFree86$ */
-#include <stdlib.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "macros.h"
#include "mtypes.h"
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c
index 71a8ed742..f03910302 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c
@@ -25,9 +25,6 @@
* 3DLabs Gamma driver.
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "gamma_context.h"
#include "gamma_vb.h"
#include "gamma_tris.h"
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c
index d3d7f019f..ac63fd12a 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c
@@ -74,8 +74,7 @@ gammaDestroyContext(__DRIcontextPrivate *driContextPriv)
static GLboolean
-gammaCreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+gammaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
@@ -103,11 +102,8 @@ gammaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
}
static void
-gammaSwapBuffers(Display *dpy, void *drawablePrivate)
+gammaSwapBuffers( __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
- (void) dpy;
-
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
gammaContextPtr gmesa;
__DRIscreenPrivate *driScrnPriv;
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810context.c b/xc/lib/GL/mesa/src/drv/i810/i810context.c
index 1fe470e1e..c6c7c1a47 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810context.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810context.c
@@ -57,9 +57,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "i810vb.h"
#include "i810ioctl.h"
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
static const GLubyte *i810GetString( GLcontext *ctx, GLenum name )
{
@@ -117,7 +114,7 @@ static const struct gl_pipeline_stage *i810_pipeline[] = {
GLboolean
-i810CreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+i810CreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate )
{
@@ -201,7 +198,6 @@ i810CreateContext( Display *dpy, const __GLcontextModes *mesaVis,
/* Dri stuff
*/
- imesa->display = dpy;
imesa->hHWContext = driContextPriv->hHWContext;
imesa->driFd = sPriv->fd;
imesa->driHwLock = &sPriv->pSAREA->lock;
@@ -372,7 +368,7 @@ void i810GetLock( i810ContextPtr imesa, GLuint flags )
* NOTE: This releases and regains the hw lock, so all state
* checking must be done *after* this call:
*/
- DRI_VALIDATE_DRAWABLE_INFO(imesa->display, sPriv, dPriv);
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
/* If we lost context, need to dump all registers to hardware.
@@ -423,11 +419,8 @@ void i810GetLock( i810ContextPtr imesa, GLuint flags )
void
-i810SwapBuffers(Display *dpy, void *drawablePrivate)
+i810SwapBuffers( __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
- (void) dpy;
-
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
i810ContextPtr imesa;
GLcontext *ctx;
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810context.h b/xc/lib/GL/mesa/src/drv/i810/i810context.h
index 0b8310735..9b76ff7e7 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810context.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810context.h
@@ -30,8 +30,6 @@ typedef struct i810_context_t i810Context;
typedef struct i810_context_t *i810ContextPtr;
typedef struct i810_texture_object_t *i810TextureObjectPtr;
-#include <X11/Xlibint.h>
-
#include "mtypes.h"
#include "mm.h"
@@ -175,7 +173,6 @@ struct i810_context_t {
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
- Display *display;
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
index 1cd1790c0..49aa4ffec 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
@@ -1,7 +1,6 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810ioctl.c,v 1.6 2002/02/22 21:33:03 dawes Exp $ */
-#include <stdio.h>
-#include <unistd.h>
+#include <unistd.h> /* for usleep() */
#include "glheader.h"
#include "mtypes.h"
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810screen.c b/xc/lib/GL/mesa/src/drv/i810/i810screen.c
index bf34ef99d..d3f932522 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810screen.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810screen.c
@@ -33,9 +33,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "context.h"
#include "matrix.h"
@@ -90,15 +87,12 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
i810ScreenPrivate *i810Screen;
I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
- /* Check the DRI version */
- {
- int major, minor, patch;
- if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
- if (major != 4 || minor < 0) {
- __driUtilMessage("i810 DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
- return GL_FALSE;
- }
- }
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "i810 DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return GL_FALSE;
}
/* Check that the DDX driver version is compatible */
@@ -217,8 +211,7 @@ i810DestroyScreen(__DRIscreenPrivate *sPriv)
static GLboolean
-i810CreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810screen.h b/xc/lib/GL/mesa/src/drv/i810/i810screen.h
index 4aedbfd76..4625bc5e9 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810screen.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810screen.h
@@ -78,7 +78,7 @@ typedef struct {
extern GLboolean
-i810CreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+i810CreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate );
@@ -94,6 +94,6 @@ i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driReadPriv);
extern void
-i810SwapBuffers(Display *dpy, void *drawablePrivate);
+i810SwapBuffers(__DRIdrawablePrivate *driDrawPriv);
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810state.c b/xc/lib/GL/mesa/src/drv/i810/i810state.c
index b82e00df2..43ab0f093 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810state.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810state.c
@@ -1,7 +1,5 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810state.c,v 1.8 2002/09/10 00:39:37 dawes Exp $ */
-#include <stdio.h>
-
#include "glheader.h"
#include "context.h"
#include "macros.h"
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tex.c b/xc/lib/GL/mesa/src/drv/i810/i810tex.c
index a8821e7d9..6f0de817d 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tex.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tex.c
@@ -23,9 +23,6 @@
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tex.c,v 1.8 2002/02/22 21:33:04 dawes Exp $ */
-#include <stdlib.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "mtypes.h"
#include "imports.h"
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810texmem.c b/xc/lib/GL/mesa/src/drv/i810/i810texmem.c
new file mode 100644
index 000000000..5f7b7fa1f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810texmem.c
@@ -0,0 +1,411 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810tex.h"
+#include "i810state.h"
+#include "i810ioctl.h"
+
+
+void i810DestroyTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
+{
+ if (!t) return;
+
+ /* This is sad - need to sync *in case* we upload a texture
+ * to this newly free memory...
+ */
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (imesa && t->age > imesa->dirtyAge)
+ imesa->dirtyAge = t->age;
+ }
+
+ if (t->globj)
+ t->globj->DriverData = 0;
+
+ if (imesa) {
+ if (imesa->CurrentTexObj[0] == t) {
+ imesa->CurrentTexObj[0] = 0;
+ imesa->dirty &= ~I810_UPLOAD_TEX0;
+ }
+
+ if (imesa->CurrentTexObj[1] == t) {
+ imesa->CurrentTexObj[1] = 0;
+ imesa->dirty &= ~I810_UPLOAD_TEX1;
+ }
+ }
+
+ remove_from_list(t);
+ free(t);
+}
+
+
+void i810SwapOutTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (t->age > imesa->dirtyAge)
+ imesa->dirtyAge = t->age;
+ }
+
+ t->dirty_images = ~0;
+ move_to_tail(&(imesa->SwappedOut), t);
+}
+
+
+
+/* Upload an image from mesa's internal copy.
+ */
+static void i810UploadTexLevel( i810TextureObjectPtr t, int level )
+{
+ const struct gl_texture_image *image = t->image[level].image;
+ int i,j;
+
+ switch (t->image[level].internalFormat) {
+ case GL_RGB:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_565( src[0], src[1], src[2] );
+ src += 3;
+ }
+ }
+ }
+ break;
+
+ case GL_RGBA:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[3], src[0], src[1], src[2] );
+ src += 4;
+ }
+ }
+ }
+ break;
+
+ case GL_LUMINANCE:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_565( src[0], src[0], src[0] );
+ src ++;
+ }
+ }
+ }
+ break;
+
+ case GL_INTENSITY:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+ int i;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[0], src[0], src[0], src[0] );
+ src ++;
+ }
+ }
+ }
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[1], src[0], src[0], src[0] );
+ src += 2;
+ }
+ }
+ }
+ break;
+
+ case GL_ALPHA:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[0], 255, 255, 255 );
+ src += 1;
+ }
+ }
+ }
+ break;
+
+ /* TODO: Translate color indices *now*:
+ */
+ case GL_COLOR_INDEX:
+ {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = src[0];
+ src += 1;
+ }
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Not supported texture format %s\n",
+ _mesa_lookup_enum_by_nr(image->Format));
+ }
+}
+
+
+
+void i810PrintLocalLRU( i810ContextPtr imesa )
+{
+ i810TextureObjectPtr t;
+ int sz = 1 << (imesa->i810Screen->logTextureGranularity);
+
+ foreach( t, &imesa->TexObjList ) {
+ if (!t->globj)
+ fprintf(stderr, "Placeholder %d at %x sz %x\n",
+ t->MemBlock->ofs / sz,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+ else
+ fprintf(stderr, "Texture at %x sz %x\n",
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+
+ }
+}
+
+void i810PrintGlobalLRU( i810ContextPtr imesa )
+{
+ int i, j;
+ I810TexRegionRec *list = imesa->sarea->texList;
+
+ for (i = 0, j = I810_NR_TEX_REGIONS ; i < I810_NR_TEX_REGIONS ; i++) {
+ fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+ j, list[j].age, list[j].next, list[j].prev);
+ j = list[j].next;
+ if (j == I810_NR_TEX_REGIONS) break;
+ }
+
+ if (j != I810_NR_TEX_REGIONS)
+ fprintf(stderr, "Loop detected in global LRU\n");
+}
+
+
+void i810ResetGlobalLRU( i810ContextPtr imesa )
+{
+ I810TexRegionRec *list = imesa->sarea->texList;
+ int sz = 1 << imesa->i810Screen->logTextureGranularity;
+ int i;
+
+ /* (Re)initialize the global circular LRU list. The last element
+ * in the array (I810_NR_TEX_REGIONS) is the sentinal. Keeping it
+ * at the end of the array allows it to be addressed rationally
+ * when looking up objects at a particular location in texture
+ * memory.
+ */
+ for (i = 0 ; (i+1) * sz <= imesa->i810Screen->textureSize ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = I810_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = I810_NR_TEX_REGIONS;
+ list[I810_NR_TEX_REGIONS].prev = i;
+ list[I810_NR_TEX_REGIONS].next = 0;
+ imesa->sarea->texAge = 0;
+}
+
+
+void i810UpdateTexLRU( i810ContextPtr imesa, i810TextureObjectPtr t )
+{
+ int i;
+ int logsz = imesa->i810Screen->logTextureGranularity;
+ int start = t->MemBlock->ofs >> logsz;
+ int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
+ I810TexRegionRec *list = imesa->sarea->texList;
+
+ imesa->texAge = ++imesa->sarea->texAge;
+
+ /* Update our local LRU
+ */
+ move_to_head( &(imesa->TexObjList), t );
+
+ /* Update the global LRU
+ */
+ for (i = start ; i <= end ; i++) {
+
+ list[i].in_use = 1;
+ list[i].age = imesa->texAge;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = I810_NR_TEX_REGIONS;
+ list[i].next = list[I810_NR_TEX_REGIONS].next;
+ list[(unsigned)list[I810_NR_TEX_REGIONS].next].prev = i;
+ list[I810_NR_TEX_REGIONS].next = i;
+ }
+}
+
+
+/* Called for every shared texture region which has increased in age
+ * since we last held the lock.
+ *
+ * Figures out which of our textures have been ejected by other clients,
+ * and pushes a placeholder texture onto the LRU list to represent
+ * the other client's textures.
+ */
+void i810TexturesGone( i810ContextPtr imesa,
+ GLuint offset,
+ GLuint size,
+ GLuint in_use )
+{
+ i810TextureObjectPtr t, tmp;
+
+ foreach_s ( t, tmp, &imesa->TexObjList ) {
+
+ if (t->MemBlock->ofs >= offset + size ||
+ t->MemBlock->ofs + t->MemBlock->size <= offset)
+ continue;
+
+ /* It overlaps - kick it off. Need to hold onto the currently bound
+ * objects, however.
+ */
+ i810SwapOutTexObj( imesa, t );
+ }
+
+ if (in_use) {
+ t = (i810TextureObjectPtr) calloc(1,sizeof(*t));
+ if (!t) return;
+
+ t->MemBlock = mmAllocMem( imesa->texHeap, size, 0, offset);
+ insert_at_head( &imesa->TexObjList, t );
+ }
+}
+
+
+
+
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+void i810UploadTexImages( i810ContextPtr imesa, i810TextureObjectPtr t )
+{
+ int i;
+ int ofs;
+ int numLevels;
+
+ LOCK_HARDWARE( imesa );
+
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->MemBlock) {
+ while (1)
+ {
+ t->MemBlock = mmAllocMem( imesa->texHeap, t->totalSize, 12, 0 );
+ if (t->MemBlock)
+ break;
+
+ if (imesa->TexObjList.prev == imesa->CurrentTexObj[0] ||
+ imesa->TexObjList.prev == imesa->CurrentTexObj[1]) {
+ fprintf(stderr, "Hit bound texture in upload\n");
+ i810PrintLocalLRU( imesa );
+ return;
+ }
+
+ if (imesa->TexObjList.prev == &(imesa->TexObjList)) {
+ fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
+ mmDumpMemInfo( imesa->texHeap );
+ return;
+ }
+
+ i810SwapOutTexObj( imesa, imesa->TexObjList.prev );
+ }
+
+ ofs = t->MemBlock->ofs;
+ t->BufAddr = imesa->i810Screen->tex.map + ofs;
+ t->Setup[I810_TEXREG_MI3] = imesa->i810Screen->textureOffset + ofs;
+
+ if (t == imesa->CurrentTexObj[0])
+ I810_STATECHANGE(imesa, I810_UPLOAD_TEX0);
+
+ if (t == imesa->CurrentTexObj[1])
+ I810_STATECHANGE(imesa, I810_UPLOAD_TEX1);
+
+ i810UpdateTexLRU( imesa, t );
+ }
+
+ if (imesa->dirtyAge >= GET_DISPATCH_AGE(imesa))
+ i810WaitAgeLocked( imesa, imesa->dirtyAge );
+
+ numLevels = t->lastLevel - t->firstLevel + 1;
+ for (i = 0 ; i < numLevels ; i++)
+ if (t->dirty_images & (1<<i))
+ i810UploadTexLevel( t, i );
+
+ t->dirty_images = 0;
+
+ UNLOCK_HARDWARE( imesa );
+}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810texstate.c b/xc/lib/GL/mesa/src/drv/i810/i810texstate.c
index 37e865c81..3ed355f4a 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810texstate.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810texstate.c
@@ -22,9 +22,6 @@
*
*/
-#include <stdlib.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "macros.h"
#include "mtypes.h"
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.c b/xc/lib/GL/mesa/src/drv/i810/i810tris.c
index 5dc352e69..5c76e645c 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tris.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.c
@@ -31,9 +31,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include <stdio.h>
-#include <math.h>
-
#include "glheader.h"
#include "mtypes.h"
#include "macros.h"
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_context.c b/xc/lib/GL/mesa/src/drv/i830/i830_context.c
index b70fa0b6c..5309b91b6 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_context.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_context.c
@@ -60,9 +60,6 @@
#include "i830_vb.h"
#include "i830_ioctl.h"
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
#ifndef I830_DEBUG
int I830_DEBUG = (0);
@@ -201,9 +198,9 @@ static void add_debug_flags( const char *debug )
}
#endif
-GLboolean i830CreateContext( Display *dpy, const __GLcontextModes *mesaVis,
- __DRIcontextPrivate *driContextPriv,
- void *sharedContextPrivate)
+GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
{
GLcontext *ctx , *shareCtx;
i830ContextPtr imesa;
@@ -277,7 +274,6 @@ GLboolean i830CreateContext( Display *dpy, const __GLcontextModes *mesaVis,
_swrast_allow_vertex_fog( ctx, GL_TRUE );
/* Dri stuff */
- imesa->display = dpy;
imesa->hHWContext = driContextPriv->hHWContext;
imesa->driFd = sPriv->fd;
imesa->driHwLock = &sPriv->pSAREA->lock;
@@ -474,7 +470,7 @@ void i830GetLock( i830ContextPtr imesa, GLuint flags )
* NOTE: This releases and regains the hw lock, so all state
* checking must be done *after* this call:
*/
- DRI_VALIDATE_DRAWABLE_INFO(imesa->display, sPriv, dPriv);
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv);
/* If we lost context, need to dump all registers to hardware.
* Note that we don't care about 2d contexts, even if they perform
@@ -529,10 +525,8 @@ void i830GetLock( i830ContextPtr imesa, GLuint flags )
sarea->last_quiescent = -1; /* just kill it for now */
}
-void i830SwapBuffers(Display *dpy, void *drawablePrivate)
+void i830SwapBuffers( __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
-
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
i830ContextPtr imesa;
GLcontext *ctx;
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_context.h b/xc/lib/GL/mesa/src/drv/i830/i830_context.h
index 6483f398e..31649c88e 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_context.h
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_context.h
@@ -209,7 +209,6 @@ struct i830_context_t
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
- Display *display;
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_debug.c b/xc/lib/GL/mesa/src/drv/i830/i830_debug.c
index fef802f8d..b452ee414 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_debug.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_debug.c
@@ -31,8 +31,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Author:
* Jeff Hartmann <jhartmann@2d3d.com>
*/
-#include <stdio.h>
-#include <unistd.h>
#include "glheader.h"
#include "context.h"
@@ -221,7 +219,6 @@ void i830VertexSanity( i830ContextPtr imesa, drmI830Vertex vertex )
"internal state\n");
fprintf(stderr, "Buffer size : %d\n", size);
fprintf(stderr, "Vertex size : %d\n", vfmt_size);
- sleep(10);
}
switch(sarea->vertex_prim) {
@@ -285,7 +282,6 @@ void i830VertexSanity( i830ContextPtr imesa, drmI830Vertex vertex )
fprintf(stderr, "temp_size : %d\n", temp_size);
fprintf(stderr, "remaining vertices : %d",
remaining / vfmt_size);
- sleep(10);
}
}
if (1) {
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c b/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c
index f4b20a5a1..b85622952 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c
@@ -38,8 +38,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include <stdio.h>
-#include <unistd.h>
+#include <unistd.h> /* for usleep() */
#include "glheader.h"
#include "mtypes.h"
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_screen.c b/xc/lib/GL/mesa/src/drv/i830/i830_screen.c
index 71ae60640..5929a2288 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_screen.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_screen.c
@@ -34,13 +34,6 @@
*/
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
-
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "context.h"
#include "matrix.h"
@@ -132,17 +125,14 @@ static GLboolean i830InitDriver(__DRIscreenPrivate *sPriv)
i830ScreenPrivate *i830Screen;
I830DRIPtr gDRIPriv = (I830DRIPtr)sPriv->pDevPriv;
- /* Check the DRI version */
- {
- int major, minor, patch;
- if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
- if (major != 4 || minor < 0) {
- __driUtilMessage("i830 DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
- return GL_FALSE;
- }
- }
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "i830 DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return GL_FALSE;
}
-
+
/* Check that the DDX driver version is compatible */
if (sPriv->ddxMajor != 1 || sPriv->ddxMinor < 0) {
__driUtilMessage("i830 DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
@@ -268,8 +258,7 @@ static void i830DestroyScreen(__DRIscreenPrivate *sPriv)
sPriv->private = NULL;
}
-static GLboolean i830CreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+static GLboolean i830CreateBuffer(__DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_screen.h b/xc/lib/GL/mesa/src/drv/i830/i830_screen.h
new file mode 100644
index 000000000..270194c87
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_screen.h
@@ -0,0 +1,115 @@
+/**************************************************************************
+
+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 PRECISION INSIGHT AND/OR ITS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Adapted for use on the I830M:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+
+#ifndef _I830_INIT_H_
+#define _I830_INIT_H_
+
+#include <sys/time.h>
+#include "dri_util.h"
+
+
+/* All structures go here */
+typedef struct
+{
+ GLubyte blue;
+ GLubyte green;
+ GLubyte red;
+ GLubyte alpha;
+}i830_color;
+
+
+
+typedef struct {
+ drmHandle handle;
+ drmSize size;
+ char *map;
+} i830Region, *i830RegionPtr;
+
+typedef struct
+{
+
+ i830Region front;
+ i830Region back;
+ i830Region depth;
+ i830Region tex;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+
+ int cpp; /* for front and back buffers */
+ int bitsPerPixel;
+
+ int fbFormat;
+ int fbOffset;
+ int fbStride;
+
+ int backOffset;
+ int depthOffset;
+
+ int backPitch;
+ int backPitchBits;
+
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+
+ __DRIscreenPrivate *driScrnPriv;
+ drmBufMapPtr bufs;
+ int use_copy_buf;
+ unsigned int sarea_priv_offset;
+}i830ScreenPrivate;
+
+
+extern GLboolean
+i830CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+
+extern void
+i830DestroyContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+i830UnbindContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+
+extern void
+i830SwapBuffers(__DRIdrawablePrivate *driDrawPriv);
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_state.c b/xc/lib/GL/mesa/src/drv/i830/i830_state.c
index d6fe88142..15e0dd495 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_state.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_state.c
@@ -34,7 +34,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Heavily based on the I810 driver, which was written by:
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include <stdio.h>
#include "glheader.h"
#include "context.h"
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c b/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c
index d54af4daf..c98327e87 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_texmem.c
@@ -35,9 +35,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Keith Whitwell <keithw@tungstengraphics.com>
*/
-#include <stdlib.h>
-#include <stdio.h>
-
#include "glheader.h"
#include "macros.h"
#include "mtypes.h"
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c b/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c
index 6faead1e6..d2cbaf3f1 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_texstate.c
@@ -34,8 +34,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Heavily based on the I810 driver, which was written by:
* Keith Whitwell <keithw@tungstengraphics.com>
*/
-#include <stdlib.h>
-#include <stdio.h>
#include "glheader.h"
#include "macros.h"
diff --git a/xc/lib/GL/mesa/src/drv/i830/i830_tris.c b/xc/lib/GL/mesa/src/drv/i830/i830_tris.c
index 970fc0888..4ae95347b 100644
--- a/xc/lib/GL/mesa/src/drv/i830/i830_tris.c
+++ b/xc/lib/GL/mesa/src/drv/i830/i830_tris.c
@@ -33,9 +33,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Jeff Hartmann <jhartmann@2d3d.com>
*/
-#include <stdio.h>
-#include <math.h>
-
#include "glheader.h"
#include "context.h"
#include "macros.h"
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
index a3715a3b6..e9d15bec5 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
@@ -28,10 +28,6 @@
#ifdef GLX_DIRECT_RENDERING
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
-#include "xf86drm.h"
#include "mga_common.h"
#include "mga_xmesa.h"
#include "context.h"
@@ -57,7 +53,6 @@
#include "mgabuffers.h"
#include "mgapixel.h"
-#include "xf86dri.h"
#include "mga_xmesa.h"
#include "mga_dri.h"
@@ -85,15 +80,12 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
fprintf(stderr, "mgaInitDriver\n");
- /* Check the DRI version */
- {
- int major, minor, patch;
- if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
- if (major != 4 || minor < 0) {
- __driUtilMessage("MGA DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
- return GL_FALSE;
- }
- }
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "MGA DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return GL_FALSE;
}
/* Check that the DDX driver version is compatible */
@@ -276,7 +268,7 @@ static const struct gl_pipeline_stage *mga_pipeline[] = {
static GLboolean
-mgaCreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+mgaCreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate )
{
@@ -310,7 +302,6 @@ mgaCreateContext( Display *dpy, const __GLcontextModes *mesaVis,
driContextPriv->driverPrivate = mmesa;
/* Init mga state */
- mmesa->display = dpy;
mmesa->hHWContext = driContextPriv->hHWContext;
mmesa->driFd = sPriv->fd;
mmesa->driHwLock = &sPriv->pSAREA->lock;
@@ -462,8 +453,7 @@ mgaDestroyContext(__DRIcontextPrivate *driContextPriv)
static GLboolean
-mgaCreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
index 0d52410d0..5da3be6dd 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
@@ -26,7 +26,6 @@
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgabuffers.c,v 1.11 2002/09/11 19:49:07 tsi Exp $ */
-#include <stdio.h>
#include "mgacontext.h"
#include "mgabuffers.h"
#include "mgastate.h"
@@ -214,7 +213,7 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
/* fprintf(stderr, "%s\n", __FUNCTION__); */
- DRI_VALIDATE_DRAWABLE_INFO(mmesa->display, mmesa->driScreen, driDrawable);
+ DRI_VALIDATE_DRAWABLE_INFO(mmesa->driScreen, driDrawable);
mmesa->dirty_cliprects = 0;
if (mmesa->draw_buffer == MGA_FRONT)
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgacontext.h b/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
index 6ca6b82b8..c74bb3f39 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
@@ -29,7 +29,6 @@
#ifndef MGALIB_INC
#define MGALIB_INC
-#include <X11/Xlibint.h>
#include "dri_util.h"
#include "mtypes.h"
#include "xf86drm.h"
@@ -236,7 +235,6 @@ struct mga_context_t {
drmContext hHWContext;
drmLock *driHwLock;
int driFd;
- Display *display;
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
struct mga_screen_private_s *mgaScreen;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgadd.c b/xc/lib/GL/mesa/src/drv/mga/mgadd.c
index 7248506c0..bbf2c9520 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgadd.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgadd.c
@@ -29,10 +29,6 @@
#include "mtypes.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
#include "mm.h"
#include "mgacontext.h"
#include "mgadd.h"
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
index 9bd3bd7a0..07b162ab8 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
@@ -27,8 +27,6 @@
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.c,v 1.14 2002/09/18 17:11:40 tsi Exp $ */
-#include <stdio.h>
-
#include "mtypes.h"
#include "macros.h"
#include "dd.h"
@@ -43,11 +41,9 @@
#include "mgaioctl.h"
#include "mgatris.h"
#include "mgabuffers.h"
-
-
-#include "xf86drm.h"
#include "mga_common.h"
+
static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
unsigned long dest,
int length)
@@ -314,9 +310,8 @@ void mgaWaitForVBlank( mgaContextPtr mmesa )
/*
* Copy the back buffer to the front buffer.
*/
-void mgaSwapBuffers(Display *dpy, void *drawablePrivate)
+void mgaSwapBuffers( __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
mgaContextPtr mmesa;
XF86DRIClipRectPtr pbox;
GLint nbox;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
index 93183f50f..463999c23 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
@@ -33,7 +33,7 @@
#include "mgacontext.h"
#include "mga_xmesa.h"
-void mgaSwapBuffers( Display *dpy, void *drawablePrivate );
+void mgaSwapBuffers( __DRIdrawablePrivate *dPriv );
void mgaWaitForVBlank( mgaContextPtr mmesa );
GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgapixel.c b/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
index 12d14561b..d3cc4de8e 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
@@ -37,10 +37,10 @@
#include "mgapixel.h"
#include "mgabuffers.h"
-#include "xf86drm.h"
#include "mga_common.h"
#include "swrast/swrast.h"
+#include "imports.h"
#define IS_AGP_MEM( mmesa, p ) \
((unsigned long)mmesa->mgaScreen->buffers.map <= ((unsigned long)p) && \
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.c b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
index 05c59c09b..5bb2e25f6 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgastate.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
@@ -26,7 +26,6 @@
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgastate.c,v 1.12 2002/02/22 21:44:55 dawes Exp $ */
-#include <stdio.h>
#include "mtypes.h"
#include "colormac.h"
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c b/xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c
index 16eb7e3e4..35df6a830 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatexcnv.c
@@ -26,9 +26,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include <stdlib.h>
-#include <stdio.h>
-
#include <GL/gl.h>
#include "mm.h"
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.c b/xc/lib/GL/mesa/src/drv/mga/mgatris.c
index 0bf5ebea1..2db3fed0f 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatris.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.c
@@ -26,9 +26,6 @@
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatris.c,v 1.9 2002/02/22 21:44:56 dawes Exp $ */
-#include <stdio.h>
-#include <math.h>
-
#include "mtypes.h"
#include "macros.h"
#include "colormac.h"
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.c b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
index 2fb870e64..57e24fa0e 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgavb.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
@@ -43,9 +43,6 @@
#include "swrast_setup/swrast_setup.h"
#include "swrast/swrast.h"
-#include <stdio.h>
-#include <stdlib.h>
-
#define MGA_TEX1_BIT 0x1
#define MGA_TEX0_BIT 0x2
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.c b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
index 54c7ebac2..e06e4c168 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_context.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
@@ -69,7 +69,7 @@ int R128_DEBUG = (0
/* Create the device specific context.
*/
-GLboolean r128CreateContext( Display *dpy, const __GLcontextModes *glVisual,
+GLboolean r128CreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate )
{
@@ -97,7 +97,6 @@ GLboolean r128CreateContext( Display *dpy, const __GLcontextModes *glVisual,
driContextPriv->driverPrivate = rmesa;
ctx = rmesa->glCtx;
- rmesa->display = dpy;
rmesa->driContext = driContextPriv;
rmesa->driScreen = sPriv;
rmesa->driDrawable = NULL;
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.h b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
index 51d96d45c..ef7d36ae0 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_context.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
@@ -38,8 +38,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
-#include <X11/Xlibint.h>
-
#include "dri_util.h"
#include "xf86drm.h"
@@ -47,7 +45,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "mtypes.h"
-#include "r128_sarea.h"
#include "r128_reg.h"
struct r128_context;
@@ -195,8 +192,6 @@ struct r128_context {
/* Mirrors of some DRI state
*/
- Display *display; /* X server display */
-
__DRIcontextPrivate *driContext; /* DRI context */
__DRIscreenPrivate *driScreen; /* DRI screen */
__DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
@@ -235,8 +230,7 @@ struct r128_context {
(rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY)
-extern GLboolean r128CreateContext( Display *dpy,
- const __GLcontextModes *glVisual,
+extern GLboolean r128CreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate );
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_lock.c b/xc/lib/GL/mesa/src/drv/r128/r128_lock.c
index 4b6bcaffa..e94d30480 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_lock.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_lock.c
@@ -67,7 +67,7 @@ void r128GetLock( r128ContextPtr rmesa, GLuint flags )
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
- DRI_VALIDATE_DRAWABLE_INFO( rmesa->display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
if ( rmesa->lastStamp != dPriv->lastStamp ) {
rmesa->lastStamp = dPriv->lastStamp;
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
index 4b01f440b..1b1898c0b 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
@@ -256,8 +256,7 @@ r128CloseFullScreen( __DRIcontextPrivate *driContextPriv )
* data.
*/
static GLboolean
-r128CreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
@@ -286,11 +285,8 @@ r128DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
/* Copy the back color buffer to the front color buffer */
static void
-r128SwapBuffers(Display *dpy, void *drawablePrivate)
+r128SwapBuffers(__DRIdrawablePrivate *dPriv)
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
- (void) dpy;
-
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
r128ContextPtr rmesa;
GLcontext *ctx;
@@ -320,15 +316,12 @@ r128InitDriver( __DRIscreenPrivate *sPriv )
{
sPriv->private = (void *) r128CreateScreen( sPriv );
- /* Check the DRI version */
- {
- int major, minor, patch;
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 4 || minor < 0 ) {
- __driUtilMessage( "R128 DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch );
- return GL_FALSE;
- }
- }
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "R128 DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return GL_FALSE;
}
/* Check that the DDX driver version is compatible */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
index 4a5cfd199..9a4e6a0ca 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
@@ -33,9 +33,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
-#include <stdio.h>
-#include <math.h>
-
#include "glheader.h"
#include "mtypes.h"
#include "colormac.h"
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_context.c b/xc/lib/GL/mesa/src/drv/r200/r200_context.c
index 90466af4b..34e44aae4 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_context.c
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_context.c
@@ -290,7 +290,7 @@ static void add_debug_flags( const char *debug )
/* Create the device specific context.
*/
-GLboolean r200CreateContext( Display *dpy, const __GLcontextModes *glVisual,
+GLboolean r200CreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
@@ -300,7 +300,6 @@ GLboolean r200CreateContext( Display *dpy, const __GLcontextModes *glVisual,
GLcontext *ctx, *shareCtx;
int i, memPerUnit;
- assert(dpy);
assert(glVisual);
assert(driContextPriv);
assert(r200Screen);
@@ -323,7 +322,6 @@ GLboolean r200CreateContext( Display *dpy, const __GLcontextModes *glVisual,
driContextPriv->driverPrivate = rmesa;
/* Init r200 context data */
- rmesa->dri.display = dpy;
rmesa->dri.context = driContextPriv;
rmesa->dri.screen = sPriv;
rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
@@ -576,11 +574,8 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
void
-r200SwapBuffers(Display *dpy, void *drawablePrivate)
+r200SwapBuffers( __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
- (void) dpy;
-
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
r200ContextPtr rmesa;
GLcontext *ctx;
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_context.h b/xc/lib/GL/mesa/src/drv/r200/r200_context.h
index aa0a469a8..2f8285f7e 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_context.h
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_context.h
@@ -37,9 +37,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
-#include <X11/Xlibint.h>
#include "dri_util.h"
-#include "xf86drm.h"
#include "radeon_common.h"
#include "macros.h"
@@ -586,8 +584,6 @@ struct r200_dma {
};
struct r200_dri_mirror {
- Display *display; /* X server display */
-
__DRIcontextPrivate *context; /* DRI context */
__DRIscreenPrivate *screen; /* DRI screen */
__DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */
@@ -896,11 +892,10 @@ static __inline GLuint r200PackColor( GLuint cpp,
extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv );
-extern GLboolean r200CreateContext( Display *dpy,
- const __GLcontextModes *glVisual,
+extern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate);
-extern void r200SwapBuffers(Display *dpy, void *drawablePrivate);
+extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv );
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_lock.c b/xc/lib/GL/mesa/src/drv/r200/r200_lock.c
index 95be651d7..b71919642 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_lock.c
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_lock.c
@@ -93,7 +93,7 @@ void r200GetLock( r200ContextPtr rmesa, GLuint flags )
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
- DRI_VALIDATE_DRAWABLE_INFO( rmesa->dri.display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
if ( rmesa->lastStamp != dPriv->lastStamp ) {
r200UpdatePageFlipping( rmesa );
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c b/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c
index 9ae0f65ad..043f4133f 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c
@@ -43,9 +43,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r200_ioctl.h"
#include "r200_pixel.h"
-#include "xf86drm.h"
-
-
static GLboolean
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_screen.c b/xc/lib/GL/mesa/src/drv/r200/r200_screen.c
index 9640a4e33..e660b826f 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_screen.c
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_screen.c
@@ -68,17 +68,12 @@ r200CreateScreen( __DRIscreenPrivate *sPriv )
r200ScreenPtr r200Screen;
RADEONDRIPtr r200DRIPriv = (RADEONDRIPtr)sPriv->pDevPriv;
- /* Check the DRI version */
- {
- int major, minor, patch;
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 4 || minor < 0 ) {
- __driUtilMessage( "R200 DRI driver expected DRI version 4.0.x "
- "but got version %d.%d.%d",
- major, minor, patch );
- return NULL;
- }
- }
+ /* Check the DRI extension version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "R200 DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return NULL;
}
/* Check that the DDX driver version is compatible */
@@ -312,11 +307,10 @@ r200InitDriver( __DRIscreenPrivate *sPriv )
* data.
*/
static GLboolean
-r200CreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- const __GLcontextModes *mesaVis,
- GLboolean isPixmap )
+r200CreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
{
if (isPixmap) {
return GL_FALSE; /* not implemented */
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_screen.h b/xc/lib/GL/mesa/src/drv/r200/r200_screen.h
index c6e6563a7..fd0ff7ab6 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_screen.h
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_screen.h
@@ -37,7 +37,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
-#include <X11/Xlibint.h>
#include "dri_util.h"
#include "xf86drm.h"
#include "radeon_common.h"
diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_texstate.c b/xc/lib/GL/mesa/src/drv/r200/r200_texstate.c
index 1883e402c..718d2b609 100644
--- a/xc/lib/GL/mesa/src/drv/r200/r200_texstate.c
+++ b/xc/lib/GL/mesa/src/drv/r200/r200_texstate.c
@@ -142,6 +142,7 @@ static void r200SetTexImages( r200ContextPtr rmesa,
lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
log2Width = tObj->Image[firstLevel]->WidthLog2;
log2Height = tObj->Image[firstLevel]->HeightLog2;
+ log2Depth = 0;
break;
case GL_TEXTURE_3D:
firstLevel = tObj->BaseLevel;
@@ -153,6 +154,7 @@ static void r200SetTexImages( r200ContextPtr rmesa,
case GL_TEXTURE_RECTANGLE_NV:
firstLevel = lastLevel = 0;
log2Width = log2Height = 1; /* ? */
+ log2Depth = 0;
break;
default:
return;
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c
index a308d72a5..e4856203c 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c
@@ -255,7 +255,7 @@ static void radeonInitDriverFuncs( GLcontext *ctx )
/* Create the device specific context.
*/
static GLboolean
-radeonCreateContext( Display *dpy, const __GLcontextModes *glVisual,
+radeonCreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
@@ -265,7 +265,6 @@ radeonCreateContext( Display *dpy, const __GLcontextModes *glVisual,
GLcontext *ctx, *shareCtx;
int i;
- assert(dpy);
assert(glVisual);
assert(driContextPriv);
assert(radeonScreen);
@@ -288,7 +287,6 @@ radeonCreateContext( Display *dpy, const __GLcontextModes *glVisual,
driContextPriv->driverPrivate = rmesa;
/* Init radeon context data */
- rmesa->dri.display = dpy;
rmesa->dri.context = driContextPriv;
rmesa->dri.screen = sPriv;
rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
@@ -618,8 +616,7 @@ radeonInitDriver( __DRIscreenPrivate *sPriv )
* data.
*/
static GLboolean
-radeonCreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
@@ -653,10 +650,8 @@ radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
static void
-radeonSwapBuffers(Display *dpy, void *drawablePrivate)
+radeonSwapBuffers( __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
- (void) dpy;
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
radeonContextPtr rmesa;
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h
index 0ac297842..29762d1dd 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h
@@ -44,6 +44,7 @@ typedef struct radeon_context radeonContextRec;
typedef struct radeon_context *radeonContextPtr;
#include "mtypes.h"
+#include "macros.h"
#include "radeon_lock.h"
#include "radeon_screen.h"
#include "mm.h"
@@ -474,8 +475,6 @@ struct radeon_dma {
};
struct radeon_dri_mirror {
- Display *display; /* X server display */
-
__DRIcontextPrivate *context; /* DRI context */
__DRIscreenPrivate *screen; /* DRI screen */
__DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c
index 36b4a24cb..b292c25d1 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c
@@ -106,7 +106,7 @@ void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
- DRI_VALIDATE_DRAWABLE_INFO( rmesa->dri.display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
if ( rmesa->lastStamp != dPriv->lastStamp ) {
radeonUpdatePageFlipping( rmesa );
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c
index fe200c8ff..75443cb1f 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c
@@ -67,17 +67,12 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
radeonScreenPtr radeonScreen;
RADEONDRIPtr radeonDRIPriv = (RADEONDRIPtr)sPriv->pDevPriv;
- /* Check the DRI version */
- {
- int major, minor, patch;
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 4 || minor < 0 ) {
- __driUtilMessage( "Radeon DRI driver expected DRI version 4.0.x "
- "but got version %d.%d.%d",
- major, minor, patch );
- return NULL;
- }
- }
+ /* Check the DRI extension version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "Radeon DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return NULL;
}
/* Check that the DDX driver version is compatible */
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_tcl.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_tcl.c
index e6501d9ca..429cef409 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_tcl.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_tcl.c
@@ -35,6 +35,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "glheader.h"
#include "imports.h"
+#include "light.h"
#include "mmath.h"
#include "mtypes.h"
#include "enums.h"
diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c b/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c
index fe0780804..a3f05b947 100644
--- a/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/sis/sis_xmesa.c
@@ -76,17 +76,13 @@ GLboolean XMesaInitDriver (__DRIscreenPrivate * driScrnPriv)
{
SISDRIPtr priv = (SISDRIPtr) driScrnPriv->pDevPriv;
- /* Check the DRI version */
- {
- int major, minor, patch;
- if (XF86DRIQueryVersion(driScrnPriv->display, &major, &minor, &patch)) {
- if (major != 4 || minor < 0) {
- char msg[1000];
- sprintf(msg, "sis DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
- __driMesaMessage(msg);
- return GL_FALSE;
- }
- }
+
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "sis DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return NULL;
}
/* Check that the DDX driver version is compatible */
@@ -211,7 +207,7 @@ GLvisual *XMesaCreateVisual(Display *dpy,
0 /* num samples */ );
}
-GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
+GLboolean XMesaCreateContext(GLvisual *mesaVis,
__DRIcontextPrivate *driContextPriv)
{
XMesaContext c;
@@ -228,12 +224,10 @@ GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
if (!c->xm_visual)
return GL_FALSE;
c->xm_visual->gl_visual = mesaVis;
- c->xm_visual->display = dpy;
c->gl_ctx = driContextPriv->mesaContext;
c->xm_buffer = NULL;
- c->display = dpy;
c->gl_ctx->Driver.UpdateState = sis_UpdateState;
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c
index f081252d1..243710b97 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c
@@ -103,7 +103,7 @@ static const struct gl_pipeline_stage *tdfx_pipeline[] = {
};
-GLboolean tdfxCreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate )
{
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h
index e11cfd1bd..59e21b0d5 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h
@@ -947,8 +947,7 @@ struct tdfx_context {
extern GLboolean
-tdfxCreateContext( Display *dpy,
- const __GLcontextModes *mesaVis,
+tdfxCreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate );
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c
index 2790caa15..f7b6b8732 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c
@@ -54,7 +54,7 @@ void tdfxGetLock( tdfxContextPtr fxMesa )
drmGetLock( fxMesa->driFd, fxMesa->hHWContext, 0 );
/* This macro will update dPriv's cliprects if needed */
- DRI_VALIDATE_DRAWABLE_INFO( cPriv->display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
if ( saPriv->fifoOwner != fxMesa->hHWContext ) {
fxMesa->Glide.grDRIImportFifo( saPriv->fifoPtr, saPriv->fifoRead );
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c
index 963a52fb3..803c8c5c1 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c
@@ -64,6 +64,7 @@
} while (0);
+#if 0
static FxBool
FX_grLfbLock(tdfxContextPtr fxMesa, GrLock_t type, GrBuffer_t buffer,
GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
@@ -76,7 +77,7 @@ FX_grLfbLock(tdfxContextPtr fxMesa, GrLock_t type, GrBuffer_t buffer,
UNLOCK_HARDWARE(fxMesa);
return result;
}
-
+#endif
#define FX_grLfbUnlock(fxMesa, t, b) \
@@ -662,7 +663,7 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
{
const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
? (fxMesa->screen_width * 4) : (info.strideInBytes);
- GLubyte *dst = (const GLubyte *) info.lfbPtr
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ scrY * dstStride + scrX * 4;
const GLint srcStride =
_mesa_image_row_stride(unpack, width, format, type);
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c
index 6ea28a255..611c13afc 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c
@@ -34,8 +34,6 @@
*
*/
-#include <X11/Xlibint.h>
-
#include "tdfx_dri.h"
#include "tdfx_context.h"
#include "tdfx_lock.h"
@@ -125,16 +123,12 @@ tdfxInitDriver( __DRIscreenPrivate *sPriv )
fprintf( stderr, "%s( %p )\n", __FUNCTION__, sPriv );
}
- /* Check the DRI version */
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 4 ||
- minor < 0 ) {
- __driUtilMessage(
- "3dfx DRI driver expected DRI version 4.0.x "
- "but got version %d.%d.%d",
- major, minor, patch );
- return GL_FALSE;
- }
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 4 || sPriv->driMinor < 0 ) {
+ __driUtilMessage( "tdfx DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return NULL;
}
/* Check that the DDX driver version is compatible */
@@ -167,8 +161,7 @@ tdfxInitDriver( __DRIscreenPrivate *sPriv )
static GLboolean
-tdfxCreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
@@ -196,9 +189,9 @@ tdfxDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
static void
-tdfxSwapBuffers(Display *dpy, void *drawablePrivate)
+tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
+
{
- __DRIdrawablePrivate *driDrawPriv = (__DRIdrawablePrivate*) drawablePrivate;
GET_CURRENT_CONTEXT(ctx);
tdfxContextPtr fxMesa = 0;
GLframebuffer *mesaBuffer;
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c
index b81ddd540..c67683ecb 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c
@@ -29,9 +29,6 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include <stdio.h>
-#include <math.h>
-
#include "glheader.h"
#include "mtypes.h"
#include "macros.h"