summaryrefslogtreecommitdiff
path: root/GL
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2006-03-12 00:11:34 +0000
committerKristian Høgsberg <krh@redhat.com>2006-03-12 00:11:34 +0000
commitc3342c8000f6d2bfb61e2cf95e028d11b59698fa (patch)
tree854fa59122eff885f4f5bcf2300bdf69b5bb2b8f /GL
parentb1b731c28630965d9e2defe62d1108270dc8264c (diff)
Merge accel_indirect branch to HEAD.
Diffstat (limited to 'GL')
-rw-r--r--GL/glx/Makefile.am33
-rw-r--r--GL/glx/g_disptab.h6
-rw-r--r--GL/glx/global.c1
-rw-r--r--GL/glx/glxbuf.c296
-rw-r--r--GL/glx/glxbuf.h57
-rw-r--r--GL/glx/glxcmds.c330
-rw-r--r--GL/glx/glxcmdsswap.c78
-rw-r--r--GL/glx/glxcontext.h50
-rw-r--r--GL/glx/glxdrawable.h35
-rw-r--r--GL/glx/glxdri.c926
-rw-r--r--GL/glx/glxext.c213
-rw-r--r--GL/glx/glxfb.c183
-rw-r--r--GL/glx/glxfb.h52
-rw-r--r--GL/glx/glximports.c188
-rw-r--r--GL/glx/glximports.h66
-rw-r--r--GL/glx/glxmem.c151
-rw-r--r--GL/glx/glxmem.h48
-rw-r--r--GL/glx/glxpix.c132
-rw-r--r--GL/glx/glxpix.h48
-rw-r--r--GL/glx/glxscreens.c191
-rw-r--r--GL/glx/glxscreens.h36
-rw-r--r--GL/glx/glxserver.h30
-rw-r--r--GL/glx/glxutil.c314
-rw-r--r--GL/glx/glxutil.h27
-rw-r--r--GL/glx/glxvisuals.c517
-rw-r--r--GL/mesa/X/xf86glx.c915
-rw-r--r--GL/mesa/X/xf86glxint.h56
-rw-r--r--GL/mesa/swrast/Makefile.am1
-rwxr-xr-xGL/symlink-mesa.sh1
29 files changed, 2320 insertions, 2661 deletions
diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index db2708335..7892dd9e5 100644
--- a/GL/glx/Makefile.am
+++ b/GL/glx/Makefile.am
@@ -1,10 +1,16 @@
-noinst_LTLIBRARIES = libglx.la
+if AIGLX
+GLXDRI_LIBRARY = libglxdri.la
+endif
+
+noinst_LTLIBRARIES = libglx.la $(GLXDRI_LIBRARY)
AM_CFLAGS = \
+ -I@MESA_SOURCE@/include \
@DIX_CFLAGS@ \
@GL_CFLAGS@ \
@XLIB_CFLAGS@ \
- -I@MESA_SOURCE@/include \
+ @LIBDRM_CFLAGS@ \
+ @DRIPROTO_CFLAGS@ \
-I@MESA_SOURCE@/src/mesa/glapi \
-I@MESA_SOURCE@/src/mesa/main \
@SERVER_DEFINES@ \
@@ -15,10 +21,20 @@ AM_CFLAGS = \
# none yet
#sdk_HEADERS =
-INCLUDES = -I$(top_srcdir)/GL/include -I$(top_srcdir)/hw/xfree86/os-support
+INCLUDES = \
+ -I$(top_srcdir)/GL/include \
+ -I$(top_srcdir)/hw/xfree86/os-support \
+ -I$(top_srcdir)/hw/xfree86/os-support/bus \
+ -I$(top_srcdir)/hw/xfree86/common \
+ -I$(top_srcdir)/hw/xfree86/dri \
+ -I$(top_srcdir)/mi
+
nodist_libglx_la_SOURCES = indirect_size.h
+libglxdri_la_SOURCES = \
+ glxdri.c
+
libglx_la_SOURCES = \
g_disptab.c \
g_disptab.h \
@@ -29,8 +45,6 @@ libglx_la_SOURCES = \
glcontextmodes.h \
global.c \
glthread.c \
- glxbuf.c \
- glxbuf.h \
glxcmds.c \
glxcmdsswap.c \
glxcontext.h \
@@ -38,14 +52,7 @@ libglx_la_SOURCES = \
glxerror.h \
glxext.c \
glxext.h \
- glxfb.c \
- glxfb.h \
- glximports.c \
- glximports.h \
- glxmem.c \
- glxmem.h \
- glxpix.c \
- glxpix.h \
+ glxvisuals.c \
glxscreens.c \
glxscreens.h \
glxserver.h \
diff --git a/GL/glx/g_disptab.h b/GL/glx/g_disptab.h
index 222c5164e..9ae901c1d 100644
--- a/GL/glx/g_disptab.h
+++ b/GL/glx/g_disptab.h
@@ -46,6 +46,9 @@ extern int __glXWaitGL(__GLXclientState*, GLbyte*);
extern int __glXWaitX(__GLXclientState*, GLbyte*);
extern int __glXCopyContext(__GLXclientState*, GLbyte*);
extern int __glXSwapBuffers(__GLXclientState*, GLbyte*);
+extern int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc);
+extern int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc);
+extern int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc);
extern int __glXUseXFont(__GLXclientState*, GLbyte*);
extern int __glXCreateGLXPixmap(__GLXclientState*, GLbyte*);
extern int __glXGetVisualConfigs(__GLXclientState*, GLbyte*);
@@ -71,6 +74,9 @@ extern int __glXSwapWaitGL(__GLXclientState*, GLbyte*);
extern int __glXSwapWaitX(__GLXclientState*, GLbyte*);
extern int __glXSwapCopyContext(__GLXclientState*, GLbyte*);
extern int __glXSwapSwapBuffers(__GLXclientState*, GLbyte*);
+extern int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc);
+extern int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc);
extern int __glXSwapUseXFont(__GLXclientState*, GLbyte*);
extern int __glXSwapCreateGLXPixmap(__GLXclientState*, GLbyte*);
extern int __glXSwapGetVisualConfigs(__GLXclientState*, GLbyte*);
diff --git a/GL/glx/global.c b/GL/glx/global.c
index 18cd5edc2..28030ec03 100644
--- a/GL/glx/global.c
+++ b/GL/glx/global.c
@@ -53,6 +53,7 @@ __GLXcontext *__glXLastContext;
RESTYPE __glXContextRes;
RESTYPE __glXClientRes;
RESTYPE __glXPixmapRes;
+RESTYPE __glXDrawableRes;
RESTYPE __glXSwapBarrierRes;
/*
diff --git a/GL/glx/glxbuf.c b/GL/glx/glxbuf.c
deleted file mode 100644
index 44be53614..000000000
--- a/GL/glx/glxbuf.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/glx/glxbuf.c,v 1.6 2001/03/25 05:32:01 tsi Exp $ */
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "glxserver.h"
-#include "glxutil.h"
-#include "glxbuf.h"
-#include "glxfb.h"
-#include "glxmem.h"
-#include "glxpix.h"
-
-void
-__glXFBInitDrawable(__GLXdrawablePrivate *glxPriv, __GLcontextModes *modes)
-{
- __GLdrawablePrivate *glPriv;
- GLint rgbBits;
- GLint accumBits;
-
- glPriv = &glxPriv->glPriv;
- rgbBits = modes->rgbBits;
- accumBits = modes->accumRedBits + modes->accumGreenBits +
- modes->accumBlueBits + modes->accumAlphaBits;
-
-#if defined(__GL_ALIGNED_BUFFERS)
- /* initialize pixel alignments (for more details see context.h) */
- glPriv->xAlignment = 1;
- glPriv->yAlignment = 1;
-#endif
-
- glxPriv->swapBuffers = __glXFBMemSwapBuffers;
-
- glPriv->yInverted = GL_TRUE; /* Y is upside-down */
-
- if (modes->doubleBufferMode) {
- if (modes->colorIndexMode) {
- __glXInitFB(&glPriv->frontBuffer, glPriv, modes->indexBits);
- __glXInitMem(&glPriv->backBuffer, glPriv, modes->indexBits);
- } else {
- __glXInitFB(&glPriv->frontBuffer, glPriv, rgbBits);
- __glXInitMem(&glPriv->backBuffer, glPriv, rgbBits);
- }
- } else {
- if (modes->colorIndexMode) {
- __glXInitFB(&glPriv->frontBuffer, glPriv, modes->indexBits);
- } else {
- __glXInitFB(&glPriv->frontBuffer, glPriv, rgbBits);
- }
- }
-
-#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
- if (modes->maxAuxBuffers > 0) {
- GLint i;
-
- for (i=0; i < modes->maxAuxBuffers; i++) {
- if (modes->colorIndexMode) {
- __glXInitMem(&glPriv->auxBuffer[i], glPriv, modes->indexBits);
- } else {
- __glXInitMem(&glPriv->auxBuffer[i], glPriv, rgbBits);
- }
- }
- }
-#endif
-
- if (modes->haveAccumBuffer) {
- __glXInitMem(&glPriv->accumBuffer, glPriv, accumBits);
- }
- if (modes->haveDepthBuffer) {
- __glXInitMem(&glPriv->depthBuffer, glPriv, modes->depthBits);
- }
- if (modes->haveStencilBuffer) {
- __glXInitMem(&glPriv->stencilBuffer, glPriv, modes->stencilBits);
- }
-}
-
-void
-__glXPixInitDrawable(__GLXdrawablePrivate *glxPriv, __GLcontextModes *modes)
-{
- __GLdrawablePrivate *glPriv;
- GLint rgbBits;
- GLint accumBits;
-
- assert(glxPriv->pGlxPixmap);
-
- glPriv = &glxPriv->glPriv;
- rgbBits = modes->rgbBits;
- accumBits = modes->accumRedBits + modes->accumGreenBits +
- modes->accumBlueBits + modes->accumAlphaBits;
-
-#if defined(__GL_ALIGNED_BUFFERS)
- /* initialize pixel alignments (for more details see context.h) */
- glPriv->xAlignment = 1;
- glPriv->yAlignment = 1;
-#endif
-
- glxPriv->swapBuffers = (GLboolean (*)(__GLXdrawablePrivate *))__glXNop;
-
- glPriv->yInverted = GL_FALSE;
-
- if (modes->doubleBufferMode) {
- if (modes->colorIndexMode) {
- __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
- glxPriv->drawId, glxPriv->pGlxPixmap);
- __glXInitMem(&glPriv->backBuffer, glPriv, modes->indexBits);
- } else {
- __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
- glxPriv->drawId, glxPriv->pGlxPixmap);
- __glXInitMem(&glPriv->backBuffer, glPriv, rgbBits);
- }
- } else {
- if (modes->colorIndexMode) {
- __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
- glxPriv->drawId, glxPriv->pGlxPixmap);
- } else {
- __glXInitPix(&glPriv->frontBuffer, glPriv, rgbBits,
- glxPriv->drawId, glxPriv->pGlxPixmap);
- }
- }
-
-#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
- if (modes->maxAuxBuffers > 0) {
- GLint i;
-
- for (i=0; i < modes->maxAuxBuffers; i++) {
- if (modes->colorIndexMode) {
- __glXInitMem(&glPriv->auxBuffer[i], glPriv, modes->indexBits);
- } else {
- __glXInitMem(&glPriv->auxBuffer[i], glPriv, rgbBits);
- }
- }
- }
-#endif
-
- if (modes->haveAccumBuffer) {
- __glXInitMem(&glPriv->accumBuffer, glPriv, accumBits);
- }
- if (modes->haveDepthBuffer) {
- __glXInitMem(&glPriv->depthBuffer, glPriv, modes->depthBits);
- }
- if (modes->haveStencilBuffer) {
- __glXInitMem(&glPriv->stencilBuffer, glPriv, modes->stencilBits);
- }
-}
-
-
-#define __GLX_SET_ACCEL_BUFFER_MASK(bm) \
- if (status == GL_FALSE) return GL_FALSE; \
- if (status == GL_TRUE) accelBufferMask |= bm; \
- /* for __GL_BUFFER_FALLBACK don't do anything */
-
-GLboolean
-__glXResizeBuffers(__GLdrawablePrivate *glPriv,
- GLint x, GLint y, GLuint width, GLuint height)
-{
- __GLcontextModes *modes;
- __GLdrawableRegion *glRegion;
- GLboolean status;
- GLuint accelBufferMask;
-
- modes = glPriv->modes;
- accelBufferMask = 0;
-
- status = (*glPriv->frontBuffer.resize)(&glPriv->frontBuffer,
- x, y, width, height, glPriv,
- __GL_FRONT_BUFFER_MASK);
- __GLX_SET_ACCEL_BUFFER_MASK(__GL_FRONT_BUFFER_MASK);
-
- if (modes->doubleBufferMode) {
- status = (*glPriv->backBuffer.resize)(&glPriv->backBuffer,
- x, y, width, height, glPriv,
- __GL_BACK_BUFFER_MASK);
- __GLX_SET_ACCEL_BUFFER_MASK(__GL_BACK_BUFFER_MASK);
- }
-
-#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
- if (modes->maxAuxBuffers > 0) {
- GLint i;
-
- for (i=0; i < modes->maxAuxBuffers; i++) {
- status = (*glPriv->auxBuffers[i].resize)(&glPriv->auxBuffer[i],
- x, y, width, height,
- glPriv,
- __GL_AUX_BUFFER_MASK(i));
- __GLX_SET_ACCEL_BUFFER_MASK(__GL_AUX_BUFFER_MASK(i));
- }
- }
-#endif
-
- if (modes->haveAccumBuffer) {
- status = (*glPriv->accumBuffer.resize)(&glPriv->accumBuffer,
- x, y, width, height, glPriv,
- __GL_ACCUM_BUFFER_MASK);
- __GLX_SET_ACCEL_BUFFER_MASK(__GL_ACCUM_BUFFER_MASK);
- }
-
- if (modes->haveDepthBuffer) {
- status = (*glPriv->depthBuffer.resize)(&glPriv->depthBuffer,
- x, y, width, height, glPriv,
- __GL_DEPTH_BUFFER_MASK);
- __GLX_SET_ACCEL_BUFFER_MASK(__GL_DEPTH_BUFFER_MASK);
- }
-
- if (modes->haveStencilBuffer) {
- status = (*glPriv->stencilBuffer.resize)(&glPriv->stencilBuffer,
- x, y, width, height, glPriv,
- __GL_STENCIL_BUFFER_MASK);
- __GLX_SET_ACCEL_BUFFER_MASK(__GL_STENCIL_BUFFER_MASK);
- }
-
- glPriv->accelBufferMask = accelBufferMask;
-
- /* finally, update the ownership region */
- glRegion = &glPriv->ownershipRegion;
- glRegion->numRects = 1;
- glRegion->rects[0].x0 = 0;
- glRegion->rects[0].y0 = 0;
- glRegion->rects[0].x1 = width;
- glRegion->rects[0].y1 = height;
-
- return GL_TRUE;
-}
-
-void
-__glXFreeBuffers(__GLXdrawablePrivate *glxPriv)
-{
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
-#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
- __GLcontextModes *modes = glPriv->modes;
-#endif
-
- if (glPriv->frontBuffer.free) {
- (*glPriv->frontBuffer.free)(&glPriv->frontBuffer, glPriv);
- }
- if (glPriv->backBuffer.free) {
- (*glPriv->backBuffer.free)(&glPriv->backBuffer, glPriv);
- }
-
-#if defined(__GL_MAX_AUXBUFFERS) && (__GL_MAX_AUXBUFFERS > 0)
- if (modes->maxAuxBuffers > 0) {
- GLint i;
-
- for (i=0; i < modes->maxAuxBuffers; i++) {
- if (glPriv->auxBuffer[i].free) {
- (*glPriv->auxBuffer[i].free)(&glPriv->auxBuffer[i], glPriv);
- }
- }
- }
-#endif
-
- if (glPriv->accumBuffer.free) {
- (*glPriv->accumBuffer.free)(&glPriv->accumBuffer, glPriv);
- }
-
- if (glPriv->depthBuffer.free) {
- (*glPriv->depthBuffer.free)(&glPriv->depthBuffer, glPriv);
- }
-
- if (glPriv->stencilBuffer.free) {
- (*glPriv->stencilBuffer.free)(&glPriv->stencilBuffer, glPriv);
- }
-}
diff --git a/GL/glx/glxbuf.h b/GL/glx/glxbuf.h
deleted file mode 100644
index 88b04e8bd..000000000
--- a/GL/glx/glxbuf.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* $XFree86$ */
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _glxbuf_h_
-#define _glxbuf_h_
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-extern void __glXFBInitDrawable(__GLXdrawablePrivate *glxPriv,
- __GLcontextModes *modes);
-extern void __glXPixInitDrawable(__GLXdrawablePrivate *glxPriv,
- __GLcontextModes *modes);
-
-extern GLboolean __glXResizeBuffers(__GLdrawablePrivate *glPriv,
- GLint x, GLint y,
- GLuint width, GLuint height);
-
-extern void __glXFreeBuffers(__GLXdrawablePrivate *glxPriv);
-extern void __glXUpdatePalette(__GLXdrawablePrivate *);
-
-#endif /* _glxbuf_h_ */
-
diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c
index c63b17008..6426e294e 100644
--- a/GL/glx/glxcmds.c
+++ b/GL/glx/glxcmds.c
@@ -49,7 +49,6 @@
#include <pixmapstr.h>
#include <windowstr.h>
#include "g_disptab_EXT.h"
-#include "glximports.h"
#include "glxutil.h"
#include "glxext.h"
#include "GL/glx_ansic.h"
@@ -61,24 +60,6 @@
/************************************************************************/
-static __GLimports imports = {
- __glXImpMalloc,
- __glXImpCalloc,
- __glXImpRealloc,
- __glXImpFree,
- __glXImpWarning,
- __glXImpFatal,
- __glXImpGetenv,
- __glXImpAtoi,
- __glXImpSprintf,
- __glXImpFopen,
- __glXImpFclose,
- __glXImpFprintf,
- __glXImpGetDrawablePrivate,
- __glXImpGetReadablePrivate,
- NULL
-};
-
static int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
static int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
static int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
@@ -94,6 +75,27 @@ static int __glxHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc);
/************************************************************************/
+static void __glXdirectContextDestroy(__GLXcontext *context)
+{
+ __glXFree(context);
+}
+
+static __GLXcontext *__glXdirectContextCreate(__GLXscreen *screen,
+ __GLcontextModes *modes,
+ __GLXcontext *shareContext)
+{
+ __GLXcontext *context;
+
+ context = __glXMalloc (sizeof (__GLXcontext));
+ if (context == NULL)
+ return NULL;
+
+ memset(context, 0, sizeof *context);
+ context->destroy = __glXdirectContextDestroy;
+
+ return context;
+}
+
/**
* Create a GL context with the given properties. This routine is used
* to implement \c glXCreateContext, \c glXCreateNewContext, and
@@ -111,8 +113,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
ScreenPtr pScreen;
__GLXcontext *glxc, *shareglxc;
__GLcontextModes *modes;
- __GLXscreenInfo *pGlxScreen;
- __GLinterface *shareGC;
+ __GLXscreen *pGlxScreen;
GLint i;
LEGAL_NEW_RESOURCE(gcId, client);
@@ -125,7 +126,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
return BadValue;
}
pScreen = screenInfo.screens[screen];
- pGlxScreen = &__glXActiveScreens[screen];
+ pGlxScreen = __glXActiveScreens[screen];
/*
** Check if the visual ID is valid for this screen.
@@ -167,7 +168,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
** for multithreaded servers, we don't do this.
*/
if (shareList == None) {
- shareGC = 0;
+ shareglxc = 0;
} else {
shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes);
if (!shareglxc) {
@@ -193,17 +194,18 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
*/
isDirect = GL_FALSE;
}
- shareGC = shareglxc->gc;
}
/*
** Allocate memory for the new context
*/
- glxc = (__GLXcontext *) __glXMalloc(sizeof(__GLXcontext));
+ if (!isDirect)
+ glxc = pGlxScreen->createContext(pGlxScreen, modes, shareglxc);
+ else
+ glxc = __glXdirectContextCreate(pGlxScreen, modes, shareglxc);
if (!glxc) {
return BadAlloc;
}
- __glXMemset(glxc, 0, sizeof(__GLXcontext));
/*
** Initially, setup the part of the context that could be used by
@@ -214,32 +216,11 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
glxc->pVisual = pVisual;
glxc->modes = modes;
- if (!isDirect) {
-
- /*
- ** Allocate a GL context
- */
- imports.other = (void *)glxc;
- glxc->gc = (*pGlxScreen->createContext)(&imports, glxc->modes, shareGC);
- if (!glxc->gc) {
- __glXFree(glxc);
- client->errorValue = gcId;
- return BadAlloc;
- }
- } else {
- /*
- ** Don't need local GL context for a direct context.
- */
- glxc->gc = 0;
- }
/*
** Register this context as a resource.
*/
if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
- if (!isDirect) {
- (*glxc->gc->exports.destroyContext)((__GLcontext *)glxc->gc);
- }
- __glXFree(glxc);
+ (*glxc->destroy)(glxc);
client->errorValue = gcId;
return BadAlloc;
}
@@ -520,9 +501,8 @@ int DoMakeCurrent( __GLXclientState *cl,
__GLXpixmap *drawPixmap = NULL;
__GLXpixmap *readPixmap = NULL;
__GLXcontext *glxc, *prevglxc;
- __GLinterface *gc, *prevgc;
- __GLXdrawablePrivate *drawPriv = NULL;
- __GLXdrawablePrivate *readPriv = NULL;
+ __GLXdrawable *drawPriv = NULL;
+ __GLXdrawable *readPriv = NULL;
GLint error;
GLuint mask;
@@ -554,10 +534,8 @@ int DoMakeCurrent( __GLXclientState *cl,
client->errorValue = prevglxc->id;
return __glXBadContextState;
}
- prevgc = prevglxc->gc;
} else {
prevglxc = 0;
- prevgc = 0;
}
/*
@@ -575,8 +553,6 @@ int DoMakeCurrent( __GLXclientState *cl,
/* Context is current to somebody else */
return BadAccess;
}
- gc = glxc->gc;
-
assert( drawId != None );
assert( readId != None );
@@ -600,14 +576,14 @@ int DoMakeCurrent( __GLXclientState *cl,
/* FIXME: Finish refactoring this. - idr */
/* get the drawable private */
if (pDraw) {
- drawPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes);
+ drawPriv = __glXGetDrawable(glxc, pDraw, drawId);
if (drawPriv == NULL) {
return __glXBadDrawable;
}
}
if (pRead != pDraw) {
- readPriv = __glXGetDrawablePrivate(pRead, readId, glxc->modes);
+ readPriv = __glXGetDrawable(glxc, pRead, readId);
if (readPriv == NULL) {
return __glXBadDrawable;
}
@@ -618,7 +594,6 @@ int DoMakeCurrent( __GLXclientState *cl,
} else {
/* Switching to no context. Ignore new drawable. */
glxc = 0;
- gc = 0;
pDraw = 0;
pRead = 0;
}
@@ -640,7 +615,7 @@ int DoMakeCurrent( __GLXclientState *cl,
/*
** Make the previous context not current.
*/
- if (!(*prevgc->exports.loseCurrent)((__GLcontext *)prevgc)) {
+ if (!(*prevglxc->loseCurrent)(prevglxc)) {
return __glXBadContext;
}
__glXDeassociateContext(prevglxc);
@@ -651,19 +626,18 @@ int DoMakeCurrent( __GLXclientState *cl,
glxc->drawPriv = drawPriv;
glxc->readPriv = readPriv;
- __glXCacheDrawableSize(drawPriv);
/* make the context current */
- if (!(*gc->exports.makeCurrent)((__GLcontext *)gc)) {
+ if (!(*glxc->makeCurrent)(glxc)) {
glxc->drawPriv = NULL;
glxc->readPriv = NULL;
return __glXBadContext;
}
/* resize the buffers */
- if (!__glXResizeDrawableBuffers(drawPriv)) {
+ if (!(*drawPriv->resize)(drawPriv)) {
/* could not do initial resize. make current failed */
- (*gc->exports.loseCurrent)((__GLcontext *)gc);
+ (*glxc->loseCurrent)(glxc);
glxc->drawPriv = NULL;
glxc->readPriv = NULL;
return __glXBadContext;
@@ -911,9 +885,7 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
/*
** Issue copy. The only reason for failure is a bad mask.
*/
- if (!(*dst->gc->exports.copyContext)((__GLcontext *)dst->gc,
- (__GLcontext *)src->gc,
- mask)) {
+ if (!(*dst->copy)(dst, src, mask)) {
client->errorValue = mask;
return BadValue;
}
@@ -926,7 +898,7 @@ int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
{
ClientPtr client = cl->client;
xGLXGetVisualConfigsReply reply;
- __GLXscreenInfo *pGlxScreen;
+ __GLXscreen *pGlxScreen;
__GLcontextModes *modes;
CARD32 buf[__GLX_TOTAL_CONFIG];
int p;
@@ -938,7 +910,7 @@ int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
client->errorValue = screen;
return BadValue;
}
- pGlxScreen = &__glXActiveScreens[screen];
+ pGlxScreen = __glXActiveScreens[screen];
reply.numVisuals = pGlxScreen->numUsableVisuals;
reply.numProps = __GLX_TOTAL_CONFIG;
@@ -1017,6 +989,68 @@ int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
}
+/* Composite adds a 32 bit ARGB visual after glxvisuals.c have created
+ * the context modes for the screens. This visual is useful for GLX
+ * pixmaps, so we create a single mode for this visual with no extra
+ * buffers. */
+static void
+__glXCreateARGBConfig(__GLXscreen *screen)
+{
+ __GLcontextModes *modes;
+ VisualPtr visual;
+ int i;
+
+ visual = NULL;
+ for (i = 0; i < screen->pScreen->numVisuals; i++)
+ if (screen->pScreen->visuals[i].nplanes == 32) {
+ visual = &screen->pScreen->visuals[i];
+ break;
+ }
+
+ if (visual == NULL || visual->class != TrueColor)
+ return;
+
+ if (_gl_context_modes_find_visual (screen->modes, visual->vid))
+ return;
+
+ /* Stop now if we already added the mode. */
+ modes = _gl_context_modes_create(1, sizeof(__GLcontextModes));
+ if (modes == NULL)
+ return;
+
+ modes->next = screen->modes;
+ screen->modes = modes;
+ screen->numUsableVisuals++;
+ screen->numVisuals++;
+
+ modes->visualID = visual->vid;
+ modes->fbconfigID = visual->vid;
+ modes->visualType = GLX_TRUE_COLOR;
+ modes->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+ modes->renderType = GLX_RGBA_BIT;
+ modes->xRenderable = GL_TRUE;
+ modes->rgbMode = TRUE;
+ modes->colorIndexMode = FALSE;
+ modes->doubleBufferMode = FALSE;
+ modes->stereoMode = FALSE;
+ modes->haveAccumBuffer = FALSE;
+
+ modes->redBits = visual->bitsPerRGBValue;;
+ modes->greenBits = visual->bitsPerRGBValue;
+ modes->blueBits = visual->bitsPerRGBValue;
+ modes->alphaBits = visual->bitsPerRGBValue;
+
+ modes->rgbBits = 4 * visual->bitsPerRGBValue;
+ modes->indexBits = 0;
+ modes->level = 0;
+ modes->numAuxBuffers = 0;
+
+ modes->haveDepthBuffer = FALSE;
+ modes->depthBits = 0;
+ modes->haveStencilBuffer = FALSE;
+ modes->stencilBits = 0;
+}
+
#define __GLX_TOTAL_FBCONFIG_ATTRIBS (28)
#define __GLX_FBCONFIG_ATTRIBS_LENGTH (__GLX_TOTAL_FBCONFIG_ATTRIBS * 2)
@@ -1034,7 +1068,7 @@ int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap)
{
ClientPtr client = cl->client;
xGLXGetFBConfigsReply reply;
- __GLXscreenInfo *pGlxScreen;
+ __GLXscreen *pGlxScreen;
CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH];
int p;
__GLcontextModes *modes;
@@ -1047,7 +1081,9 @@ int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap)
client->errorValue = screen;
return BadValue;
}
- pGlxScreen = &__glXActiveScreens[screen];
+ pGlxScreen = __glXActiveScreens[screen];
+
+ __glXCreateARGBConfig(pGlxScreen);
reply.numFBConfigs = pGlxScreen->numUsableVisuals;
reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS;
@@ -1145,7 +1181,7 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
ScreenPtr pScreen;
VisualPtr pVisual;
__GLXpixmap *pGlxPixmap;
- __GLXscreenInfo *pGlxScreen;
+ __GLXscreen *pGlxScreen;
__GLcontextModes *modes;
int i;
@@ -1188,7 +1224,7 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
/*
** Get configuration of the visual.
*/
- pGlxScreen = &__glXActiveScreens[screenNum];
+ pGlxScreen = __glXActiveScreens[screenNum];
modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual );
if (modes == NULL) {
/*
@@ -1339,16 +1375,16 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
}
if (pDraw) {
- __GLXdrawablePrivate *glxPriv;
+ __GLXdrawable *glxPriv;
if (glxc) {
- glxPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes);
+ glxPriv = __glXGetDrawable(glxc, pDraw, drawId);
if (glxPriv == NULL) {
return __glXBadDrawable;
}
}
else {
- glxPriv = __glXFindDrawablePrivate(drawId);
+ glxPriv = __glXFindDrawable(drawId);
if (glxPriv == NULL) {
/* This is a window we've never seen before, do nothing */
return Success;
@@ -1412,6 +1448,136 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
}
+int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
+ ClientPtr client = cl->client;
+ __GLXpixmap *pGlxPixmap;
+ __GLXcontext *context;
+ GLXDrawable drawId;
+ int buffer;
+ int error;
+
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+
+ drawId = *((CARD32 *) (pc));
+ buffer = *((INT32 *) (pc + 4));
+
+ if (buffer != GLX_FRONT_LEFT_EXT)
+ return __glXBadPixmap;
+
+ context = __glXForceCurrent (cl, req->contextTag, &error);
+ if (!context)
+ return error;
+
+ pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
+ if (!pGlxPixmap) {
+ client->errorValue = drawId;
+ return __glXBadPixmap;
+ }
+
+ if (!context->textureFromPixmap)
+ return __glXUnsupportedPrivateRequest;
+
+ return context->textureFromPixmap->bindTexImage(context,
+ buffer,
+ pGlxPixmap);
+}
+
+int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
+ ClientPtr client = cl->client;
+ __GLXpixmap *pGlxPixmap;
+ __GLXcontext *context;
+ GLXDrawable drawId;
+ int buffer;
+ int error;
+
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+
+ drawId = *((CARD32 *) (pc));
+ buffer = *((INT32 *) (pc + 4));
+
+ context = __glXForceCurrent (cl, req->contextTag, &error);
+ if (!context)
+ return error;
+
+ pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
+ if (!pGlxPixmap) {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ if (!context->textureFromPixmap)
+ return __glXUnsupportedPrivateRequest;
+
+ return context->textureFromPixmap->releaseTexImage(context,
+ buffer,
+ pGlxPixmap);
+}
+
+#ifndef GLX_TEXTURE_TARGET_EXT
+#define GLX_TEXTURE_TARGET_EXT 0x6001
+#define GLX_TEXTURE_2D_EXT 0x6002
+#define GLX_TEXTURE_RECTANGLE_EXT 0x6003
+#define GLX_NO_TEXTURE_EXT 0x6004
+#define GLX_Y_INVERTED_EXT 0x6006
+#endif
+
+/*
+** Get drawable attributes
+*/
+static int
+DoGetDrawableAttributes(__GLXclientState *cl, XID drawId)
+{
+ ClientPtr client = cl->client;
+ __GLXpixmap *glxPixmap;
+ xGLXGetDrawableAttributesReply reply;
+ CARD32 attributes[2];
+ int numAttribs;
+
+ glxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
+ if (!glxPixmap) {
+ client->errorValue = drawId;
+ return __glXBadPixmap;
+ }
+
+ numAttribs = 2;
+ reply.length = numAttribs << 1;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.numAttribs = numAttribs;
+
+ attributes[0] = GLX_TEXTURE_TARGET_EXT;
+ attributes[1] = GLX_TEXTURE_RECTANGLE_EXT;
+ attributes[2] = GLX_Y_INVERTED_EXT;
+ attributes[3] = GL_FALSE;
+
+ if (client->swapped) {
+ __glXSwapGetDrawableAttributesReply(client, &reply, attributes);
+ } else {
+ WriteToClient(client, sz_xGLXGetDrawableAttributesReply,
+ (char *)&reply);
+ WriteToClient(client, reply.length * sizeof (CARD32),
+ (char *)attributes);
+ }
+
+ return Success;
+}
+
+int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc;
+ CARD32 *data;
+ XID drawable;
+
+ data = (CARD32 *) (req + 1);
+ drawable = data[0];
+
+ return DoGetDrawableAttributes(cl, drawable);
+}
+
/************************************************************************/
/*
@@ -1985,6 +2151,10 @@ int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc)
return Success;
case X_GLXvop_BindSwapBarrierSGIX:
return __glXBindSwapBarrierSGIX(cl, pc);
+ case X_GLXvop_BindTexImageEXT:
+ return __glXBindTexImageEXT(cl, pc);
+ case X_GLXvop_ReleaseTexImageEXT:
+ return __glXReleaseTexImageEXT(cl, pc);
}
#endif
@@ -2030,6 +2200,8 @@ int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
return __glXCreateContextWithConfigSGIX(cl, pc);
case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
return __glXCreateGLXPixmapWithConfigSGIX(cl, pc);
+ case X_GLXvop_GetDrawableAttributesSGIX:
+ return __glXGetDrawableAttributesSGIX(cl, pc);
default:
break;
}
@@ -2064,7 +2236,7 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
return BadValue;
}
- ptr = __glXActiveScreens[screen].GLXextensions;
+ ptr = __glXActiveScreens[screen]->GLXextensions;
n = __glXStrlen(ptr) + 1;
length = __GLX_PAD(n) >> 2;
@@ -2111,13 +2283,13 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
}
switch(name) {
case GLX_VENDOR:
- ptr = __glXActiveScreens[screen].GLXvendor;
+ ptr = __glXActiveScreens[screen]->GLXvendor;
break;
case GLX_VERSION:
- ptr = __glXActiveScreens[screen].GLXversion;
+ ptr = __glXActiveScreens[screen]->GLXversion;
break;
case GLX_EXTENSIONS:
- ptr = __glXActiveScreens[screen].GLXextensions;
+ ptr = __glXActiveScreens[screen]->GLXextensions;
break;
default:
return BadValue;
diff --git a/GL/glx/glxcmdsswap.c b/GL/glx/glxcmdsswap.c
index 5729cf851..e14106913 100644
--- a/GL/glx/glxcmdsswap.c
+++ b/GL/glx/glxcmdsswap.c
@@ -40,6 +40,7 @@
#include <dix-config.h>
#endif
+#include <string.h>
#include "glxserver.h"
#include "glxutil.h"
#include <GL/glxtokens.h>
@@ -389,6 +390,64 @@ int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
return __glXQueryContextInfoEXT(cl, pc);
}
+int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
+ GLXDrawable *drawId;
+ int *buffer;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+
+ drawId = ((GLXDrawable *) (pc));
+ buffer = ((int *) (pc + 4));
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(drawId);
+ __GLX_SWAP_INT(buffer);
+
+ return __glXBindTexImageEXT(cl, (GLbyte *)pc);
+}
+
+int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
+ GLXDrawable *drawId;
+ int *buffer;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ pc += __GLX_VENDPRIV_HDR_SIZE;
+
+ drawId = ((GLXDrawable *) (pc));
+ buffer = ((int *) (pc + 4));
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(drawId);
+ __GLX_SWAP_INT(buffer);
+
+ return __glXReleaseTexImageEXT(cl, (GLbyte *)pc);
+}
+
+int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc;
+ CARD32 *data;
+
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ data = (CARD32 *) (req + 1);
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+ __GLX_SWAP_INT(data);
+
+ return __glXGetDrawableAttributesSGIX(cl, (GLbyte *)pc);
+}
+
+
/************************************************************************/
/*
@@ -463,6 +522,19 @@ void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXT
WriteToClient(client, length << 2, (char *)buf);
}
+void __glXSwapGetDrawableAttributesReply(ClientPtr client,
+ xGLXGetDrawableAttributesReply *reply, CARD32 *buf)
+{
+ int length = reply->length;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->numAttribs);
+ WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)reply);
+ __GLX_SWAP_INT_ARRAY((int *)buf, length);
+ WriteToClient(client, length << 2, (char *)buf);
+}
/************************************************************************/
@@ -824,6 +896,10 @@ int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc)
__GLX_SWAP_INT(pc + 4);
CALL_SamplePatternSGIS( GET_DISPATCH(), (*(GLenum *)(pc + 4)) );
return Success;
+ case X_GLXvop_BindTexImageEXT:
+ return __glXSwapBindTexImageEXT(cl, pc);
+ case X_GLXvop_ReleaseTexImageEXT:
+ return __glXSwapReleaseTexImageEXT(cl, pc);
}
#endif
@@ -861,6 +937,8 @@ int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
return __glXSwapCreateContextWithConfigSGIX(cl, pc);
case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
return __glXSwapCreateGLXPixmapWithConfigSGIX(cl, pc);
+ case X_GLXvop_GetDrawableAttributesSGIX:
+ return __glXSwapGetDrawableAttributesSGIX(cl, pc);
default:
break;
}
diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h
index 18d8b44c2..5c27aa0b8 100644
--- a/GL/glx/glxcontext.h
+++ b/GL/glx/glxcontext.h
@@ -41,32 +41,48 @@
**
*/
-typedef struct __GLXcontextRec __GLXcontext;
-
/* XXX: should be defined somewhere globally */
#define CAPI
#include "GL/internal/glcore.h"
-struct __GLXcontextRec {
+typedef struct __GLXtextureFromPixmap __GLXtextureFromPixmap;
+struct __GLXtextureFromPixmap {
+ int (*bindTexImage) (__GLXcontext *baseContext,
+ int buffer,
+ __GLXpixmap *pixmap);
+ int (*releaseTexImage) (__GLXcontext *baseContext,
+ int buffer,
+ __GLXpixmap *pixmap);
+};
+
+
+struct __GLXcontext {
+ void (*destroy) (__GLXcontext *context);
+ int (*makeCurrent) (__GLXcontext *context);
+ int (*loseCurrent) (__GLXcontext *context);
+ int (*copy) (__GLXcontext *dst,
+ __GLXcontext *src,
+ unsigned long mask);
+ int (*forceCurrent) (__GLXcontext *context);
+
+ __GLXdrawable *(*createDrawable)(__GLXcontext *context,
+ DrawablePtr pDraw,
+ XID drawId);
+
+ __GLXtextureFromPixmap *textureFromPixmap;
+
/*
** list of context structs
*/
- struct __GLXcontextRec *last;
- struct __GLXcontextRec *next;
+ __GLXcontext *last;
+ __GLXcontext *next;
/*
** list of contexts bound to the same drawable
*/
- struct __GLXcontextRec *nextDrawPriv;
- struct __GLXcontextRec *nextReadPriv;
-
- /*
- ** Opaque pointer the context object created by the GL that the
- ** server is bound with. Never dereferenced by this code, but used
- ** as a handle to feed to the routines in the screen info struct.
- */
- __GLinterface *gc;
+ __GLXcontext *nextDrawPriv;
+ __GLXcontext *nextReadPriv;
/*
** mode struct for this context
@@ -78,7 +94,7 @@ struct __GLXcontextRec {
** when the context is created.
*/
ScreenPtr pScreen;
- __GLXscreenInfo *pGlxScreen;
+ __GLXscreen *pGlxScreen;
/*
** This context is created with respect to this visual.
@@ -152,8 +168,8 @@ struct __GLXcontextRec {
/*
** The drawable private this context is bound to
*/
- __GLXdrawablePrivate *drawPriv;
- __GLXdrawablePrivate *readPriv;
+ __GLXdrawable *drawPriv;
+ __GLXdrawable *readPriv;
};
/* pending state defines */
diff --git a/GL/glx/glxdrawable.h b/GL/glx/glxdrawable.h
index 38a05bfeb..2d5d07a79 100644
--- a/GL/glx/glxdrawable.h
+++ b/GL/glx/glxdrawable.h
@@ -45,19 +45,23 @@ typedef struct {
DrawablePtr pDraw;
__GLcontextModes *modes;
- __GLXscreenInfo *pGlxScreen;
+ __GLXscreen *pGlxScreen;
ScreenPtr pScreen;
Bool idExists;
int refcnt;
} __GLXpixmap;
-struct __GLXdrawablePrivateRec {
+struct __GLXdrawable {
+ void (*destroy)(__GLXdrawable *private);
+ GLboolean (*resize)(__GLXdrawable *private);
+ GLboolean (*swapBuffers)(__GLXdrawable *);
+
/*
** list of drawable private structs
*/
- struct __GLXdrawablePrivateRec *last;
- struct __GLXdrawablePrivateRec *next;
+ __GLXdrawable *last;
+ __GLXdrawable *next;
DrawablePtr pDraw;
XID drawId;
@@ -76,32 +80,13 @@ struct __GLXdrawablePrivateRec {
__GLcontextModes *modes;
/*
- ** cached drawable size and origin
- */
-
- GLint xorigin, yorigin;
- GLint width, height;
-
- /*
** Lists of contexts bound to this drawable. There are two lists here.
** One list is of the contexts that have this drawable bound for drawing,
** and the other is the list of contexts that have this drawable bound
** for reading.
*/
- struct __GLXcontextRec *drawGlxc;
- struct __GLXcontextRec *readGlxc;
-
- /*
- ** "methods" that the drawble should be able to respond to.
- */
- void (*freeBuffers)(struct __GLXdrawablePrivateRec *);
- void (*updatePalette)(struct __GLXdrawablePrivateRec *);
- GLboolean (*swapBuffers)(struct __GLXdrawablePrivateRec *);
-
- /*
- ** The GL drawable (information shared between GLX and the GL core)
- */
- __GLdrawablePrivate glPriv;
+ __GLXcontext *drawGlxc;
+ __GLXcontext *readGlxc;
/*
** reference count
diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
new file mode 100644
index 000000000..a78af1b06
--- /dev/null
+++ b/GL/glx/glxdri.c
@@ -0,0 +1,926 @@
+/*
+ * Copyright © 2006 Red Hat, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of Red Hat,
+ * Inc not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL RED HAT, INC BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <dlfcn.h>
+
+#include <drm.h>
+#include <GL/gl.h>
+#include <GL/internal/dri_interface.h>
+
+#include <windowstr.h>
+#include <os.h>
+
+#define _XF86DRI_SERVER_
+#include <drm_sarea.h>
+#include <xf86drm.h>
+#include <xf86dristr.h>
+#include <xf86str.h>
+#include <xf86.h>
+#include <dri.h>
+
+#define DRI_NEW_INTERFACE_ONLY
+#include "glxserver.h"
+#include "glxutil.h"
+#include "glcontextmodes.h"
+
+#include "g_disptab.h"
+#include "g_disptab_EXT.h"
+#include "glapitable.h"
+#include "glapi.h"
+#include "glthread.h"
+#include "dispatch.h"
+
+
+#define STRINGIFY(macro_or_string) STRINGIFY_ARG (macro_or_string)
+#define STRINGIFY_ARG(contents) #contents
+
+typedef struct __GLXDRIscreen __GLXDRIscreen;
+typedef struct __GLXDRIcontext __GLXDRIcontext;
+typedef struct __GLXDRIdrawable __GLXDRIdrawable;
+
+struct __GLXDRIscreen {
+ __GLXscreen base;
+
+ __DRIscreen driScreen;
+ void *driver;
+};
+
+struct __GLXDRIcontext {
+ __GLXcontext base;
+
+ __DRIcontext driContext;
+};
+
+struct __GLXDRIdrawable {
+ __GLXdrawable base;
+
+ __DRIdrawable *driDrawable;
+};
+
+/* History:
+ * 20021121 - Initial version
+ * 20021128 - Added __glXWindowExists() function
+ * 20021207 - Added support for dynamic GLX extensions,
+ * GLX_SGI_swap_control, GLX_SGI_video_sync,
+ * GLX_OML_sync_control, and GLX_MESA_swap_control.
+ * Never officially released. Do NOT test against
+ * this version. Use 20030317 instead.
+ * 20030317 - Added support GLX_SGIX_fbconfig,
+ * GLX_MESA_swap_frame_usage, GLX_OML_swap_method,
+ * GLX_{ARB,SGIS}_multisample, and
+ * GLX_SGIX_visual_select_group.
+ * 20030606 - Added support for GLX_SGI_make_current_read.
+ * 20030813 - Made support for dynamic extensions multi-head aware.
+ * 20030818 - Added support for GLX_MESA_allocate_memory in place of the
+ * deprecated GLX_NV_vertex_array_range & GLX_MESA_agp_offset
+ * interfaces.
+ * 20031201 - Added support for the first round of DRI interface changes.
+ * Do NOT test against this version! It has binary
+ * compatibility bugs, use 20040317 instead.
+ * 20040317 - Added the 'mode' field to __DRIcontextRec.
+ * 20040415 - Added support for bindContext3 and unbindContext3.
+ * 20040602 - Add __glXGetDrawableInfo. I though that was there
+ * months ago. :(
+ * 20050727 - Gut all the old interfaces. This breaks compatability with
+ * any DRI driver built to any previous version.
+ */
+#define INTERNAL_VERSION 20050727
+
+static const char CREATE_NEW_SCREEN_FUNC[] =
+ "__driCreateNewScreen_" STRINGIFY (INTERNAL_VERSION);
+
+static void
+__glXDRIleaveServer(void)
+{
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ DRIDoBlockHandler(i, NULL, NULL, NULL);
+}
+
+static void
+__glXDRIenterServer(void)
+{
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ DRIDoWakeupHandler(i, NULL, 0, NULL);
+}
+
+static void
+__glXDRIdrawableDestroy(__GLXdrawable *private)
+{
+#if 0
+ (*glxPriv->driDrawable.destroyDrawable)(NULL,
+ glxPriv->driDrawable.private);
+#endif
+
+ __glXFree(private);
+}
+
+static GLboolean
+__glXDRIdrawableResize(__GLXdrawable *glxPriv)
+{
+ /* Nothing to do here, the DRI driver asks the server for drawable
+ * geometry when it sess the SAREA timestamps change.*/
+
+ return GL_TRUE;
+}
+
+static GLboolean
+__glXDRIdrawableSwapBuffers(__GLXdrawable *basePrivate)
+{
+ __GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate;
+ __GLXDRIscreen *screen;
+
+ /* FIXME: We're jumping through hoops here to get the DRIdrawable
+ * which the dri driver tries to keep to it self... cf. FIXME in
+ * createDrawable. */
+
+ screen = (__GLXDRIscreen *) __glXgetActiveScreen(private->base.pDraw->pScreen->myNum);
+ private->driDrawable = (screen->driScreen.getDrawable)(NULL,
+ private->base.drawId,
+ screen->driScreen.private);
+
+ (*private->driDrawable->swapBuffers)(NULL,
+ private->driDrawable->private);
+
+ return TRUE;
+}
+
+static __GLXdrawable *
+__glXDRIcontextCreateDrawable(__GLXcontext *context,
+ DrawablePtr pDraw,
+ XID drawId)
+{
+ __GLXDRIdrawable *private;
+
+ private = __glXMalloc(sizeof *private);
+ if (private == NULL)
+ return NULL;
+
+ memset(private, 0, sizeof *private);
+
+ if (!__glXDrawableInit(&private->base, context, pDraw, drawId)) {
+ __glXFree(private);
+ return NULL;
+ }
+
+ private->base.destroy = __glXDRIdrawableDestroy;
+ private->base.resize = __glXDRIdrawableResize;
+ private->base.swapBuffers = __glXDRIdrawableSwapBuffers;
+
+#if 0
+ /* FIXME: It would only be natural that we called
+ * driScreen->createNewDrawable here but the DRI drivers manage
+ * them a little oddly. FIXME: describe this better.*/
+
+ /* The last argument is 'attrs', which is used with pbuffers which
+ * we currently don't support. */
+
+ glxPriv->driDrawable.private =
+ (pGlxScreen->driScreen.createNewDrawable)(NULL, modes,
+ drawId,
+ &glxPriv->driDrawable,
+ 0,
+ NULL);
+#endif
+
+ return &private->base;
+}
+
+
+static void
+__glXDRIcontextDestroy(__GLXcontext *baseContext)
+{
+ __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
+
+ context->driContext.destroyContext(NULL,
+ context->base.pScreen->myNum,
+ context->driContext.private);
+ __glXFree(context);
+}
+
+static int
+__glXDRIcontextMakeCurrent(__GLXcontext *baseContext)
+{
+ __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
+
+ return (*context->driContext.bindContext)(NULL,
+ context->base.pScreen->myNum,
+ baseContext->drawPriv->drawId,
+ baseContext->readPriv->drawId,
+ &context->driContext);
+}
+
+static int
+__glXDRIcontextLoseCurrent(__GLXcontext *baseContext)
+{
+ __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
+
+ return (*context->driContext.unbindContext)(NULL,
+ context->base.pScreen->myNum,
+ baseContext->drawPriv->drawId,
+ baseContext->readPriv->drawId,
+ &context->driContext);
+}
+
+static int
+__glXDRIcontextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc,
+ unsigned long mask)
+{
+ __GLXDRIcontext *dst = (__GLXDRIcontext *) baseDst;
+ __GLXDRIcontext *src = (__GLXDRIcontext *) baseSrc;
+
+ /* FIXME: We will need to add DRIcontext::copyContext for this. */
+
+ (void) dst;
+ (void) src;
+
+ return FALSE;
+}
+
+static int
+__glXDRIcontextForceCurrent(__GLXcontext *baseContext)
+{
+ __GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
+
+ return (*context->driContext.bindContext)(NULL,
+ context->base.pScreen->myNum,
+ baseContext->drawPriv->drawId,
+ baseContext->readPriv->drawId,
+ &context->driContext);
+}
+
+static int
+glxCountBits(int word)
+{
+ int ret = 0;
+
+ while (word) {
+ ret += (word & 1);
+ word >>= 1;
+ }
+
+ return ret;
+}
+
+static void
+glxFillAlphaChannel (PixmapPtr pixmap)
+{
+ int i, j;
+ CARD32 *pixels = (CARD32 *)pixmap->devPrivate.ptr;
+ CARD32 rowstride = pixmap->devKind / 4;
+ CARD32 x, y;
+
+ x = pixmap->drawable.x;
+ y = pixmap->drawable.y;
+
+ for (i = y; i < pixmap->drawable.height + y; ++i)
+ {
+ for (j = x; j < pixmap->drawable.width + x; ++j)
+ {
+ int index = i * rowstride + j;
+
+ pixels[index] |= 0xFF000000;
+ }
+ }
+}
+
+/*
+ * (sticking this here for lack of a better place)
+ * Known issues with the GLX_EXT_texture_from_pixmap implementation:
+ * - In general we ignore the fbconfig, lots of examples follow
+ * - No fbconfig handling for multiple mipmap levels
+ * - No fbconfig handling for 1D textures
+ * - No fbconfig handling for TEXTURE_TARGET
+ * - No fbconfig exposure of Y inversion state
+ * - No GenerateMipmapEXT support (due to no FBO support)
+ * - No damage tracking between binds
+ * - No support for anything but 16bpp and 32bpp-sparse pixmaps
+ */
+
+static int
+__glXDRIbindTexImage(__GLXcontext *baseContext,
+ int buffer,
+ __GLXpixmap *glxPixmap)
+{
+ PixmapPtr pixmap;
+ int bpp;
+ Bool npot;
+
+ pixmap = (PixmapPtr) glxPixmap->pDraw;
+ bpp = pixmap->drawable.depth >= 24 ? 4 : 2; /* XXX 24bpp packed, 8, etc */
+
+ CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,
+ pixmap->devKind / bpp) );
+ CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS,
+ pixmap->drawable.y) );
+ CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS,
+ pixmap->drawable.x) );
+
+ if (pixmap->drawable.depth == 24)
+ glxFillAlphaChannel(pixmap);
+
+ npot = !(glxCountBits(pixmap->drawable.width) == 1 &&
+ glxCountBits(pixmap->drawable.height) == 1) /* ||
+ strstr(CALL_GetString(GL_EXTENSIONS,
+ "GL_ARB_texture_non_power_of_two")) */ ;
+
+ CALL_TexImage2D( GET_DISPATCH(),
+ ( npot ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D,
+ 0,
+ bpp == 4 ? 4 : 3,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ 0,
+ bpp == 4 ? GL_BGRA : GL_RGB,
+ bpp == 4 ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
+ pixmap->devPrivate.ptr ) );
+
+ return Success;
+}
+
+static int
+__glXDRIreleaseTexImage(__GLXcontext *baseContext,
+ int buffer,
+ __GLXpixmap *pixmap)
+{
+ return Success;
+}
+
+static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
+ __glXDRIbindTexImage,
+ __glXDRIreleaseTexImage
+};
+
+static void
+__glXDRIscreenDestroy(__GLXscreen *baseScreen)
+{
+ __GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
+
+ screen->driScreen.destroyScreen(NULL,
+ screen->base.pScreen->myNum,
+ screen->driScreen.private);
+
+ dlclose(screen->driver);
+
+ __glXScreenDestroy(baseScreen);
+
+ __glXFree(screen);
+}
+
+static __GLXcontext *
+__glXDRIscreenCreateContext(__GLXscreen *baseScreen,
+ __GLcontextModes *modes,
+ __GLXcontext *baseShareContext)
+{
+ __GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
+ __GLXDRIcontext *context, *shareContext;
+ void *sharePrivate;
+
+ shareContext = (__GLXDRIcontext *) baseShareContext;
+ if (shareContext)
+ sharePrivate = shareContext->driContext.private;
+ else
+ sharePrivate = NULL;
+
+ context = __glXMalloc(sizeof *context);
+ if (context == NULL)
+ return NULL;
+
+ memset(context, 0, sizeof *context);
+ context->base.destroy = __glXDRIcontextDestroy;
+ context->base.makeCurrent = __glXDRIcontextMakeCurrent;
+ context->base.loseCurrent = __glXDRIcontextLoseCurrent;
+ context->base.copy = __glXDRIcontextCopy;
+ context->base.forceCurrent = __glXDRIcontextForceCurrent;
+ context->base.createDrawable = __glXDRIcontextCreateDrawable;
+
+ context->base.textureFromPixmap = &__glXDRItextureFromPixmap;
+
+ context->driContext.private =
+ screen->driScreen.createNewContext(NULL, modes,
+ 0, /* render type */
+ sharePrivate,
+ &context->driContext);
+
+ context->driContext.mode = modes;
+
+ return &context->base;
+}
+
+static unsigned
+filter_modes(__GLcontextModes **server_modes,
+ const __GLcontextModes *driver_modes)
+{
+ __GLcontextModes * m;
+ __GLcontextModes ** prev_next;
+ const __GLcontextModes * check;
+ unsigned modes_count = 0;
+
+ if ( driver_modes == NULL ) {
+ LogMessage(X_WARNING,
+ "AIGLX: 3D driver returned no fbconfigs.\n");
+ return 0;
+ }
+
+ /* For each mode in server_modes, check to see if a matching mode exists
+ * in driver_modes. If not, then the mode is not available.
+ */
+
+ prev_next = server_modes;
+ for ( m = *prev_next ; m != NULL ; m = *prev_next ) {
+ GLboolean do_delete = GL_TRUE;
+
+ for ( check = driver_modes ; check != NULL ; check = check->next ) {
+ if ( _gl_context_modes_are_same( m, check ) ) {
+ do_delete = GL_FALSE;
+ break;
+ }
+ }
+
+ /* The 3D has to support all the modes that match the GLX visuals
+ * sent from the X server.
+ */
+ if ( do_delete && (m->visualID != 0) ) {
+ do_delete = GL_FALSE;
+
+ LogMessage(X_WARNING,
+ "AIGLX: 3D driver claims to not support "
+ "visual 0x%02x\n", m->visualID);
+ }
+
+ if ( do_delete ) {
+ *prev_next = m->next;
+
+ m->next = NULL;
+ _gl_context_modes_destroy( m );
+ }
+ else {
+ modes_count++;
+ prev_next = & m->next;
+ }
+ }
+
+ return modes_count;
+}
+
+
+static __DRIfuncPtr getProcAddress(const char *proc_name)
+{
+ return NULL;
+}
+
+static __DRIscreen *findScreen(__DRInativeDisplay *dpy, int scrn)
+{
+ __GLXDRIscreen *screen =
+ (__GLXDRIscreen *) __glXgetActiveScreen(scrn);
+
+ return &screen->driScreen;
+}
+
+static GLboolean windowExists(__DRInativeDisplay *dpy, __DRIid draw)
+{
+ WindowPtr pWin = (WindowPtr) LookupIDByType(draw, RT_WINDOW);
+
+ return pWin == NULL ? GL_FALSE : GL_TRUE;
+}
+
+static GLboolean createContext(__DRInativeDisplay *dpy, int screen,
+ int configID, void *contextID,
+ drm_context_t *hw_context)
+{
+ XID fakeID;
+ VisualPtr visual;
+ int i;
+ ScreenPtr pScreen;
+ GLboolean retval;
+
+ pScreen = screenInfo.screens[screen];
+
+ /* Find the requested X visual */
+ visual = pScreen->visuals;
+ for (i = 0; i < pScreen->numVisuals; i++, visual++)
+ if (visual->vid == configID)
+ break;
+ if (i == pScreen->numVisuals)
+ return GL_FALSE;
+
+ fakeID = FakeClientID(0);
+ *(XID *) contextID = fakeID;
+
+ __glXDRIenterServer();
+ retval = DRICreateContext(pScreen, visual, fakeID, hw_context);
+ __glXDRIleaveServer();
+ return retval;
+}
+
+static GLboolean destroyContext(__DRInativeDisplay *dpy, int screen,
+ __DRIid context)
+{
+ GLboolean retval;
+
+ __glXDRIenterServer();
+ retval = DRIDestroyContext(screenInfo.screens[screen], context);
+ __glXDRIleaveServer();
+ return retval;
+}
+
+static GLboolean
+createDrawable(__DRInativeDisplay *dpy, int screen,
+ __DRIid drawable, drm_drawable_t *hHWDrawable)
+{
+ DrawablePtr pDrawable;
+ GLboolean retval;
+
+ pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE);
+ if (!pDrawable)
+ return GL_FALSE;
+
+ __glXDRIenterServer();
+ retval = DRICreateDrawable(screenInfo.screens[screen],
+ drawable,
+ pDrawable,
+ hHWDrawable);
+ __glXDRIleaveServer();
+ return retval;
+}
+
+static GLboolean
+destroyDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable)
+{
+ DrawablePtr pDrawable;
+ GLboolean retval;
+
+ pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE);
+ if (!pDrawable)
+ return GL_FALSE;
+
+ __glXDRIenterServer();
+ retval = DRIDestroyDrawable(screenInfo.screens[screen],
+ drawable,
+ pDrawable);
+ __glXDRIleaveServer();
+ return retval;
+}
+
+static GLboolean
+getDrawableInfo(__DRInativeDisplay *dpy, int screen,
+ __DRIid drawable, unsigned int *index, unsigned int *stamp,
+ int *x, int *y, int *width, int *height,
+ int *numClipRects, drm_clip_rect_t **ppClipRects,
+ int *backX, int *backY,
+ int *numBackClipRects, drm_clip_rect_t **ppBackClipRects)
+{
+ DrawablePtr pDrawable;
+ drm_clip_rect_t *pClipRects, *pBackClipRects;
+ GLboolean retval;
+ size_t size;
+
+ pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE);
+ if (!pDrawable) {
+ ErrorF("getDrawableInfo failed to look up window\n");
+
+ *index = 0;
+ *stamp = 0;
+ *x = 0;
+ *y = 0;
+ *width = 0;
+ *height = 0;
+ *numClipRects = 0;
+ *ppClipRects = NULL;
+ *backX = 0;
+ *backY = 0;
+ *numBackClipRects = 0;
+ *ppBackClipRects = NULL;
+
+ return GL_FALSE;
+ }
+
+ __glXDRIenterServer();
+ retval = DRIGetDrawableInfo(screenInfo.screens[screen],
+ pDrawable, index, stamp,
+ x, y, width, height,
+ numClipRects, &pClipRects,
+ backX, backY,
+ numBackClipRects, &pBackClipRects);
+ __glXDRIleaveServer();
+
+ if (*numClipRects > 0) {
+ size = sizeof (drm_clip_rect_t) * *numClipRects;
+ *ppClipRects = __glXMalloc (size);
+ if (*ppClipRects != NULL)
+ memcpy (*ppClipRects, pClipRects, size);
+ }
+ else {
+ *ppClipRects = NULL;
+ }
+
+ if (*numBackClipRects > 0) {
+ size = sizeof (drm_clip_rect_t) * *numBackClipRects;
+ *ppBackClipRects = __glXMalloc (size);
+ if (*ppBackClipRects != NULL)
+ memcpy (*ppBackClipRects, pBackClipRects, size);
+ }
+ else {
+ *ppBackClipRects = NULL;
+ }
+
+ return GL_TRUE;
+}
+
+static int
+getUST(int64_t *ust)
+{
+ struct timeval tv;
+
+ if (ust == NULL)
+ return -EFAULT;
+
+ if (gettimeofday(&tv, NULL) == 0) {
+ ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
+ return 0;
+ } else {
+ return -errno;
+ }
+}
+
+/* Table of functions that we export to the driver. */
+static const __DRIinterfaceMethods interface_methods = {
+ getProcAddress,
+
+ _gl_context_modes_create,
+ _gl_context_modes_destroy,
+
+ findScreen,
+ windowExists,
+
+ createContext,
+ destroyContext,
+
+ createDrawable,
+ destroyDrawable,
+ getDrawableInfo,
+
+ getUST,
+ NULL, /* glXGetMscRateOML, */
+};
+
+static const char dri_driver_path[] = DRI_DRIVER_PATH;
+
+static __GLXscreen *
+__glXDRIscreenProbe(ScreenPtr pScreen)
+{
+ PFNCREATENEWSCREENFUNC createNewScreen;
+ drm_handle_t hSAREA;
+ drmAddress pSAREA = NULL;
+ char *BusID;
+ __DRIversion ddx_version;
+ __DRIversion dri_version;
+ __DRIversion drm_version;
+ __DRIframebuffer framebuffer;
+ int fd = -1;
+ int status;
+ const char *err_msg;
+ const char *err_extra = NULL;
+ int api_ver = INTERNAL_VERSION;
+ drm_magic_t magic;
+ drmVersionPtr version;
+ char *driverName;
+ drm_handle_t hFB;
+ int junk;
+ __GLcontextModes * driver_modes;
+ __GLXDRIscreen *screen;
+ void *dev_priv = NULL;
+ char filename[128];
+
+ screen = __glXMalloc(sizeof *screen);
+ if (screen == NULL)
+ return NULL;
+ memset(screen, 0, sizeof *screen);
+
+ screen->base.destroy = __glXDRIscreenDestroy;
+ screen->base.createContext = __glXDRIscreenCreateContext;
+ screen->base.pScreen = pScreen;
+
+ /* DRI protocol version. */
+ dri_version.major = XF86DRI_MAJOR_VERSION;
+ dri_version.minor = XF86DRI_MINOR_VERSION;
+ dri_version.patch = XF86DRI_PATCH_VERSION;
+
+ framebuffer.base = NULL;
+ framebuffer.dev_priv = NULL;
+
+ if (!DRIOpenConnection(pScreen, &hSAREA, &BusID)) {
+ err_msg = "DRIOpenConnection";
+ err_extra = NULL;
+ goto handle_error;
+ }
+
+ fd = drmOpen(NULL, BusID);
+
+ if (fd < 0) {
+ err_msg = "open DRM";
+ err_extra = strerror( -fd );
+ goto handle_error;
+ }
+
+ if (drmGetMagic(fd, &magic)) {
+ err_msg = "drmGetMagic";
+ goto handle_error;
+ }
+
+ version = drmGetVersion(fd);
+ if (version) {
+ drm_version.major = version->version_major;
+ drm_version.minor = version->version_minor;
+ drm_version.patch = version->version_patchlevel;
+ drmFreeVersion(version);
+ }
+ else {
+ drm_version.major = -1;
+ drm_version.minor = -1;
+ drm_version.patch = -1;
+ }
+
+ if (!DRIAuthConnection(pScreen, magic)) {
+ err_msg = "DRIAuthConnection";
+ goto handle_error;
+ }
+
+ /* Get device name (like "tdfx") and the ddx version numbers.
+ * We'll check the version in each DRI driver's "createNewScreen"
+ * function. */
+ if (!DRIGetClientDriverName(pScreen,
+ &ddx_version.major,
+ &ddx_version.minor,
+ &ddx_version.patch,
+ &driverName)) {
+ err_msg = "DRIGetClientDriverName";
+ goto handle_error;
+ }
+
+ snprintf(filename, sizeof filename, "%s/%s_dri.so",
+ dri_driver_path, driverName);
+
+ screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
+ if (screen->driver == NULL) {
+ err_msg = "Loading driver";
+ err_extra = filename;
+ goto handle_error;
+ }
+
+ createNewScreen = dlsym(screen->driver, CREATE_NEW_SCREEN_FUNC);
+ if (createNewScreen == NULL) {
+ err_msg = "Driver entry point lookup";
+ err_extra = CREATE_NEW_SCREEN_FUNC;
+ goto handle_error;
+ }
+
+ /*
+ * Get device-specific info. pDevPriv will point to a struct
+ * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that
+ * has information about the screen size, depth, pitch, ancilliary
+ * buffers, DRM mmap handles, etc.
+ */
+ if (!DRIGetDeviceInfo(pScreen, &hFB, &junk,
+ &framebuffer.size, &framebuffer.stride,
+ &framebuffer.dev_priv_size, &framebuffer.dev_priv)) {
+ err_msg = "XF86DRIGetDeviceInfo";
+ goto handle_error;
+ }
+
+ /* Sigh... the DRI interface is broken; the DRI driver will free
+ * the dev private pointer using _mesa_free() on screen destroy,
+ * but we can't use _mesa_malloc() here. In fact, the DRI driver
+ * shouldn't free data it didn't allocate itself, but what can you
+ * do... */
+ dev_priv = __glXMalloc(framebuffer.dev_priv_size);
+ if (dev_priv == NULL) {
+ err_msg = "dev_priv allocation";
+ goto handle_error;
+ }
+ memcpy(dev_priv, framebuffer.dev_priv, framebuffer.dev_priv_size);
+ framebuffer.dev_priv = dev_priv;
+
+ framebuffer.width = pScreen->width;
+ framebuffer.height = pScreen->height;
+
+ /* Map the framebuffer region. */
+ status = drmMap(fd, hFB, framebuffer.size,
+ (drmAddressPtr)&framebuffer.base);
+ if (status != 0) {
+ err_msg = "drmMap of framebuffer";
+ err_extra = strerror( -status );
+ goto handle_error;
+ }
+
+ /* Map the SAREA region. Further mmap regions may be setup in
+ * each DRI driver's "createNewScreen" function.
+ */
+ status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA);
+ if (status != 0) {
+ err_msg = "drmMap of sarea";
+ err_extra = strerror( -status );
+ goto handle_error;
+ }
+
+ driver_modes = NULL;
+ screen->driScreen.private =
+ (*createNewScreen)(NULL, pScreen->myNum,
+ &screen->driScreen,
+ screen->base.modes,
+ &ddx_version,
+ &dri_version,
+ &drm_version,
+ &framebuffer,
+ pSAREA,
+ fd,
+ api_ver,
+ &interface_methods,
+ &driver_modes);
+
+ if (screen->driScreen.private == NULL) {
+ err_msg = "InitDriver";
+ err_extra = NULL;
+ goto handle_error;
+ }
+
+ __glXScreenInit(&screen->base, pScreen);
+
+ filter_modes(&screen->base.modes, driver_modes);
+ _gl_context_modes_destroy(driver_modes);
+
+ __glXsetEnterLeaveServerFuncs(__glXDRIenterServer, __glXDRIleaveServer);
+
+ LogMessage(X_INFO,
+ "AIGLX: Loaded and initialized %s\n", filename);
+
+ return &screen->base;
+
+ handle_error:
+ if (pSAREA != NULL)
+ drmUnmap(pSAREA, SAREA_MAX);
+
+ if (framebuffer.base != NULL)
+ drmUnmap((drmAddress)framebuffer.base, framebuffer.size);
+
+ if (dev_priv != NULL)
+ __glXFree(dev_priv);
+
+ if (fd >= 0)
+ drmClose(fd);
+
+ DRICloseConnection(pScreen);
+
+ if (screen->driver)
+ dlclose(screen->driver);
+
+ xfree(screen);
+
+ if (err_extra != NULL)
+ LogMessage(X_ERROR,
+ "AIGLX error: %s failed (%s)\n", err_msg, err_extra);
+ else
+ LogMessage(X_ERROR, "AIGLX error: %s failed\n", err_msg);
+
+ ErrorF("GLX-DRI: reverting to software rendering\n");
+
+ return NULL;
+}
+
+__GLXprovider __glXDRIProvider = {
+ __glXDRIscreenProbe,
+ "DRI",
+ NULL
+};
diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index fa1382983..e4ad47803 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -23,6 +23,7 @@
#include <dix-config.h>
#endif
+#include <string.h>
#include "glxserver.h"
#include <windowstr.h>
#include <propertyst.h>
@@ -31,19 +32,12 @@
#include "unpack.h"
#include "glxutil.h"
#include "glxext.h"
-#include "micmap.h"
-
-void GlxWrapInitVisuals(miInitVisualsProcPtr *);
-void GlxSetVisualConfigs(int nconfigs,
- __GLXvisualConfig *configs, void **privates);
-
-static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */;
+static Bool inDispatch;
/*
** Forward declarations.
*/
-static int __glXSwapDispatch(ClientPtr);
static int __glXDispatch(ClientPtr);
/*
@@ -52,8 +46,7 @@ static int __glXDispatch(ClientPtr);
static void ResetExtension(ExtensionEntry* extEntry)
{
__glXFlushContextCache();
- (*__glXExt->resetExtension)();
- __glXScreenReset();
+ __glXResetScreens();
}
/*
@@ -159,24 +152,64 @@ static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id)
}
/*
+** Destroy routine that gets called when a drawable is freed. A drawable
+** contains the ancillary buffers needed for rendering.
+*/
+static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid)
+{
+ __GLXcontext *cx, *cx1;
+
+ /*
+ ** Use glxPriv->type to figure out what kind of drawable this is. Don't
+ ** use glxPriv->pDraw->type because by the time this routine is called,
+ ** the pDraw might already have been freed.
+ */
+ if (glxPriv->type == DRAWABLE_WINDOW) {
+ /*
+ ** When a window is destroyed, notify all context bound to
+ ** it, that there are no longer bound to anything.
+ */
+ for (cx = glxPriv->drawGlxc; cx; cx = cx1) {
+ cx1 = cx->nextDrawPriv;
+ cx->pendingState |= __GLX_PENDING_DESTROY;
+ }
+
+ for (cx = glxPriv->readGlxc; cx; cx = cx1) {
+ cx1 = cx->nextReadPriv;
+ cx->pendingState |= __GLX_PENDING_DESTROY;
+ }
+ }
+
+ __glXUnrefDrawable(glxPriv);
+
+ return True;
+}
+
+/*
** Free a context.
*/
GLboolean __glXFreeContext(__GLXcontext *cx)
{
if (cx->idExists || cx->isCurrent) return GL_FALSE;
- if (!cx->isDirect) {
- if ((*cx->gc->exports.destroyContext)((__GLcontext *)cx->gc) == GL_FALSE) {
- return GL_FALSE;
- }
- }
if (cx->feedbackBuf) __glXFree(cx->feedbackBuf);
if (cx->selectBuf) __glXFree(cx->selectBuf);
- __glXFree(cx);
if (cx == __glXLastContext) {
__glXFlushContextCache();
}
+ /* We can get here through both regular dispatching from
+ * __glXDispatch() or as a callback from the resource manager. In
+ * the latter case we need to lift the DRI lock manually. */
+
+ if (!inDispatch)
+ __glXleaveServer();
+
+ cx->destroy(cx);
+
+ if (!inDispatch)
+ __glXenterServer();
+
return GL_TRUE;
}
@@ -240,13 +273,14 @@ void GlxExtensionInit(void)
__glXContextRes = CreateNewResourceType((DeleteType)ContextGone);
__glXClientRes = CreateNewResourceType((DeleteType)ClientGone);
__glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone);
+ __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
/*
** Add extension to server extensions.
*/
extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
__GLX_NUMBER_ERRORS, __glXDispatch,
- __glXSwapDispatch, ResetExtension,
+ __glXDispatch, ResetExtension,
StandardMinorOpcode);
if (!extEntry) {
FatalError("__glXExtensionInit: AddExtensions failed\n");
@@ -280,53 +314,7 @@ void GlxExtensionInit(void)
/*
** Initialize screen specific data.
*/
- __glXScreenInit(screenInfo.numScreens);
-}
-
-/************************************************************************/
-
-Bool __glXCoreType(void)
-{
- return __glXExt->type;
-}
-
-/************************************************************************/
-
-void GlxSetVisualConfigs(int nconfigs,
- __GLXvisualConfig *configs, void **privates)
-{
- (*__glXExt->setVisualConfigs)(nconfigs, configs, privates);
-}
-
-static miInitVisualsProcPtr saveInitVisualsProc;
-
-Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB,
- int preferredVis)
-{
- Bool ret;
-
- if (saveInitVisualsProc) {
- ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
- rootDepthp, defaultVisp, sizes, bitsPerRGB,
- preferredVis);
- if (!ret)
- return False;
- }
- (*__glXExt->initVisuals)(visualp, depthp, nvisualp, ndepthp, rootDepthp,
- defaultVisp, sizes, bitsPerRGB);
- return True;
-}
-
-void
-GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
-{
- saveInitVisualsProc = *initVisProc;
- *initVisProc = GlxInitVisuals;
- /* HACK: this shouldn't be done here but it's the earliest time */
- __glXExt = __glXglDDXExtensionInfo(); /* from GLcore */
+ __glXInitScreens();
}
/************************************************************************/
@@ -377,7 +365,7 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
/* Make this context the current one for the GL. */
if (!cx->isDirect) {
- if (!(*cx->gc->exports.forceCurrent)((__GLcontext *)cx->gc)) {
+ if (!(*cx->forceCurrent)(cx)) {
/* Bind failed, and set the error code. Bummer */
cl->client->errorValue = cx->id;
*error = __glXBadContextState;
@@ -393,12 +381,51 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
/*
** Top level dispatcher; all commands are executed from here down.
*/
+
+/* I cried when I wrote this. Damn you XAA! */
+
+static void
+__glXnopEnterServer(void)
+{
+}
+
+static void
+__glXnopLeaveServer(void)
+{
+}
+
+static void (*__glXenterServerFunc)(void) = __glXnopEnterServer;
+static void (*__glXleaveServerFunc)(void) = __glXnopLeaveServer;
+
+void __glXsetEnterLeaveServerFuncs(void (*enter)(void),
+ void (*leave)(void))
+{
+ __glXenterServerFunc = enter;
+ __glXleaveServerFunc = leave;
+}
+
+
+void __glXenterServer(void)
+{
+ (*__glXenterServerFunc)();
+}
+
+void __glXleaveServer(void)
+{
+ (*__glXleaveServerFunc)();
+}
+
+
+/*
+** Top level dispatcher; all commands are executed from here down.
+*/
static int __glXDispatch(ClientPtr client)
{
REQUEST(xGLXSingleReq);
CARD8 opcode;
int (*proc)(__GLXclientState *cl, GLbyte *pc);
__GLXclientState *cl;
+ int retval;
opcode = stuff->glxCode;
cl = __glXClients[client->index];
@@ -443,54 +470,22 @@ static int __glXDispatch(ClientPtr client)
/*
** Use the opcode to index into the procedure table.
*/
- proc = __glXSingleTable[opcode];
- return (*proc)(cl, (GLbyte *) stuff);
-}
+ if (client->swapped)
+ proc = __glXSwapSingleTable[opcode];
+ else
+ proc = __glXSingleTable[opcode];
-static int __glXSwapDispatch(ClientPtr client)
-{
- REQUEST(xGLXSingleReq);
- CARD8 opcode;
- int (*proc)(__GLXclientState *cl, GLbyte *pc);
- __GLXclientState *cl;
+ __glXleaveServer();
- opcode = stuff->glxCode;
- cl = __glXClients[client->index];
- if (!cl) {
- cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
- __glXClients[client->index] = cl;
- if (!cl) {
- return BadAlloc;
- }
- __glXMemset(cl, 0, sizeof(__GLXclientState));
- }
-
- if (!cl->inUse) {
- /*
- ** This is first request from this client. Associate a resource
- ** with the client so we will be notified when the client dies.
- */
- XID xid = FakeClientID(client->index);
- if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
- return BadAlloc;
- }
- ResetClientState(client->index);
- cl->inUse = GL_TRUE;
- cl->client = client;
- }
+ inDispatch = True;
- /*
- ** Check for valid opcode.
- */
- if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
- return BadRequest;
- }
+ retval = proc(cl, (GLbyte *) stuff);
- /*
- ** Use the opcode to index into the procedure table.
- */
- proc = __glXSwapSingleTable[opcode];
- return (*proc)(cl, (GLbyte *) stuff);
+ inDispatch = False;
+
+ __glXenterServer();
+
+ return retval;
}
int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc)
diff --git a/GL/glx/glxfb.c b/GL/glx/glxfb.c
deleted file mode 100644
index 0d433d25d..000000000
--- a/GL/glx/glxfb.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* $XFree86$ */
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-/*
-** An implementation of a buffer which is part of the front buffer
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "glxserver.h"
-#include "glxutil.h"
-#include "glxfb.h"
-
-#include <gcstruct.h>
-
-/* so we don't include glmath.h */
-extern GLuint __glFloorLog2(GLuint);
-
-typedef struct __GLFBbufferInfoRec {
- GCPtr pGC;
-} __GLFBbufferInfo;
-
-extern PixmapPtr __glXPrivPixGetPtr(__GLdrawableBuffer *);
-
-/* ---------------------------------------------------------- */
-
-static GLboolean
-Resize(__GLdrawableBuffer *buf,
- GLint x, GLint y, GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv, GLuint bufferMask)
-{
- buf->width = width;
- buf->height = height;
- buf->byteWidth = width * buf->elementSize;
- buf->outerWidth = width;
-
- return GL_TRUE;
-}
-
-static void
-Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
-}
-
-static void
-Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
-}
-
-/*
-** Do a swap buffer with
-** a memory surface as a back buffer
-** a FB surface as a front buffer
-*/
-GLboolean
-__glXFBMemSwapBuffers(__GLXdrawablePrivate *glxPriv)
-{
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
- __GLdrawableBuffer *front = &glPriv->frontBuffer;
- __GLdrawableBuffer *back = &glPriv->backBuffer;
- __GLFBbufferInfo *bufferInfo;
- GCPtr pGC;
- GLint width, height, depth, pad;
- GLubyte *buf;
-
- bufferInfo = (__GLFBbufferInfo *) front->other;
- pGC = bufferInfo->pGC;
-
- width = back->width;
- height = back->height;
- depth = back->depth;
- buf = back->base;
- pad = back->outerWidth - back->width; /* back buffer padding */
- /* adjust buffer padding. X wants left, GL has right */
- buf -= pad;
-
- ValidateGC(glxPriv->pDraw, pGC);
- (*pGC->ops->PutImage)(glxPriv->pDraw, pGC,
- depth,
- 0, 0, width, height,
- pad, ZPixmap,
- (char *)buf);
-
- return GL_TRUE;
-}
-
-static void
-Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
- __GLFBbufferInfo *bufferInfo;
-
- bufferInfo = (__GLFBbufferInfo *) buf->other;
-
- if (bufferInfo->pGC) {
- FreeScratchGC(bufferInfo->pGC);
- }
-
- __glXFree(bufferInfo);
- buf->other = NULL;
-}
-
-/*
-** function to return the X GC of this buffer (to be used by DDX)
-*/
-GCPtr __glXFBGetGC(__GLdrawableBuffer *buf)
-{
- __GLFBbufferInfo *bufferInfo;
-
- bufferInfo = (__GLFBbufferInfo *) buf->other;
-
- if (bufferInfo) {
- return bufferInfo->pGC;
- } else {
- return NULL;
- }
-}
-
-
-void
-__glXInitFB(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, GLint bits)
-{
- __GLFBbufferInfo *bufferInfo;
- __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *) glPriv->other;
- GCPtr pGC;
-
- buf->depth = bits;
- buf->width = buf->height = 0; /* to be filled during Update */
- buf->handle = buf->base = NULL; /* to be filled during Update */
- buf->size = 0;
- buf->byteWidth = 0;
- buf->elementSize = ((bits-1) / 8) + 1;
- buf->elementSizeLog2 = __glFloorLog2(buf->elementSize);
-
- buf->resize = Resize;
- buf->lock = Lock;
- buf->unlock = Unlock;
- buf->fill = NULL;
- buf->free = Free;
-
- /* allocate local information */
- bufferInfo = (__GLFBbufferInfo *) __glXMalloc(sizeof(__GLFBbufferInfo));
- buf->other = (void *) bufferInfo;
-
- pGC = CreateScratchGC(glxPriv->pDraw->pScreen,
- glxPriv->pDraw->depth);
- bufferInfo->pGC = pGC;
- (*pGC->funcs->ChangeClip)(pGC, CT_NONE, NULL, 0);
-}
diff --git a/GL/glx/glxfb.h b/GL/glx/glxfb.h
deleted file mode 100644
index 325146d43..000000000
--- a/GL/glx/glxfb.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* $XFree86$ */
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _glxfb_h_
-#define _glxfb_h_
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-extern void __glXInitFB(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
- GLint bits);
-
-extern GCPtr __glXFBGetGC(__GLdrawableBuffer *buf);
-
-extern GLboolean __glXFBMemSwapBuffers(__GLXdrawablePrivate *glxPriv);
-
-#endif /* _glxfb_h_ */
-
diff --git a/GL/glx/glximports.c b/GL/glx/glximports.c
deleted file mode 100644
index a443495c4..000000000
--- a/GL/glx/glximports.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/glx/glximports.c,v 1.5 2001/03/21 16:29:36 dawes Exp $ */
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "glxserver.h"
-#include "glxcontext.h"
-#include "glximports.h"
-#include "GL/glx_ansic.h"
-
-void *__glXImpMalloc(__GLcontext *gc, size_t size)
-{
- void *addr;
-
- if (size == 0) {
- return NULL;
- }
- addr = xalloc(size);
- if (addr == NULL) {
- /* XXX: handle out of memory error */
- return NULL;
- }
- return addr;
-}
-
-void *__glXImpCalloc(__GLcontext *gc, size_t numElements, size_t elementSize)
-{
- void *addr;
- size_t size;
-
- if ((numElements == 0) || (elementSize == 0)) {
- return NULL;
- }
- size = numElements * elementSize;
- addr = xalloc(size);
- if (addr == NULL) {
- /* XXX: handle out of memory error */
- return NULL;
- }
- /* zero out memory */
- __glXMemset(addr, 0, size);
-
- return addr;
-}
-
-void __glXImpFree(__GLcontext *gc, void *addr)
-{
- if (addr) {
- xfree(addr);
- }
-}
-
-void *__glXImpRealloc(__GLcontext *gc, void *addr, size_t newSize)
-{
- void *newAddr;
-
- if (addr) {
- if (newSize == 0) {
- xfree(addr);
- return NULL;
- }
- newAddr = xrealloc(addr, newSize);
- } else {
- if (newSize == 0) {
- return NULL;
- }
- newAddr = xalloc(newSize);
- }
- if (newAddr == NULL) {
- return NULL; /* XXX: out of memory error */
- }
-
- return newAddr;
-}
-
-void __glXImpWarning(__GLcontext *gc, char *msg)
-{
- ErrorF((char *)msg);
-}
-
-void __glXImpFatal(__GLcontext *gc, char *msg)
-{
- ErrorF((char *)msg);
- __glXAbort();
-}
-
-char *__glXImpGetenv(__GLcontext *gc, const char *var)
-{
- return __glXGetenv(var);
-}
-
-int __glXImpAtoi(__GLcontext *gc, const char *str)
-{
- return __glXAtoi(str);
-}
-
-int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- /* have to deal with var args */
- va_start(ap, fmt);
- ret = __glXVsprintf(str, fmt, ap);
- va_end(ap);
-
- return ret;
-}
-
-void *__glXImpFopen(__GLcontext *gc, const char *path, const char *mode)
-{
- return (void *) __glXFopen(path, mode);
-}
-
-int __glXImpFclose(__GLcontext *gc, void *stream)
-{
- return __glXFclose((FILE *)stream);
-}
-
-int __glXImpFprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- /* have to deal with var args */
- va_start(ap, fmt);
- ret = __glXVfprintf((FILE *)stream, fmt, ap);
- va_end(ap);
-
- return ret;
-}
-
-
-__GLdrawablePrivate *__glXImpGetDrawablePrivate(__GLcontext *gc)
-{
- __GLinterface *glci = (__GLinterface *) gc;
- __GLXcontext *glrc = (__GLXcontext *) glci->imports.other;
-
- return &glrc->drawPriv->glPriv;
-}
-
-
-__GLdrawablePrivate *__glXImpGetReadablePrivate(__GLcontext *gc)
-{
- __GLinterface *glci = (__GLinterface *) gc;
- __GLXcontext *glrc = (__GLXcontext *) glci->imports.other;
-
- return &glrc->readPriv->glPriv;
-}
diff --git a/GL/glx/glximports.h b/GL/glx/glximports.h
deleted file mode 100644
index ef485822e..000000000
--- a/GL/glx/glximports.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/glx/glximports.h,v 1.3 2001/03/21 16:29:36 dawes Exp $ */
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _glximports_h_
-#define _glximports_h_
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-extern void *__glXImpMalloc(__GLcontext *gc, size_t size);
-extern void *__glXImpCalloc(__GLcontext *gc, size_t nElem, size_t eSize);
-extern void *__glXImpRealloc(__GLcontext *gc, void *addr, size_t newSize);
-extern void __glXImpFree(__GLcontext *gc, void *addr);
-
-extern void __glXImpWarning(__GLcontext *gc, char *msg);
-extern void __glXImpFatal(__GLcontext *gc, char *msg);
-
-extern char *__glXImpGetenv(__GLcontext *gc, const char *var);
-extern int __glXImpAtoi(__GLcontext *gc, const char *str);
-extern int __glXImpSprintf(__GLcontext *gc, char *str, const char *fmt, ...);
-extern void *__glXImpFopen(__GLcontext *gc, const char *path,
- const char *mode);
-extern int __glXImpFclose(__GLcontext *gc, void *stream);
-extern int __glXImpFprintf(__GLcontext *gc, void *stream,
- const char *fmt, ...);
-
-extern __GLdrawablePrivate *__glXImpGetDrawablePrivate(__GLcontext *gc);
-extern __GLdrawablePrivate *__glXImpGetReadablePrivate(__GLcontext *gc);
-
-
-#endif /* _glximports_h_ */
-
diff --git a/GL/glx/glxmem.c b/GL/glx/glxmem.c
deleted file mode 100644
index 21a7c7962..000000000
--- a/GL/glx/glxmem.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/glx/glxmem.c,v 1.6 2001/10/31 22:50:27 tsi Exp $ */
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-/*
-** Implementation of a buffer in main memory
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "glxserver.h"
-#include "glxmem.h"
-#include "glxext.h"
-#include "GL/internal/glcore.h"
-
-/* don't want to include glmath.h */
-extern GLuint __glFloorLog2(GLuint);
-
-/* ---------------------------------------------------------- */
-
-#define BUF_ALIGN 32 /* x86 cache alignment (used for assembly paths) */
-#define BUF_ALIGN_MASK (BUF_ALIGN-1)
-
-static GLboolean
-Resize(__GLdrawableBuffer *buf,
- GLint x, GLint y, GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv, GLuint bufferMask)
-{
- GLuint newSize;
- void *ubase;
- GLint pixelWidth;
- GLint alignedWidth;
-
- /*
- ** Note:
- ** buf->handle : unaligned base
- ** buf->base : aligned base
- */
-
- pixelWidth = BUF_ALIGN / buf->elementSize;
- alignedWidth = (width & ~(pixelWidth-1)) + pixelWidth;
-
- newSize = alignedWidth * height * buf->elementSize;
-
- /*
- ** Only allocate buffer space for the SGI core.
- ** Mesa and Aqua handle their own buffer allocations.
- */
-#if defined(__GL_BUFFER_SIZE_TRACKS_WINDOW)
- if (__glXCoreType() == GL_CORE_SGI) {
-#else
- if (newSize > buf->size && __glXCoreType() == GL_CORE_SGI) {
-#endif
- if (buf->handle) {
- ubase = (*glPriv->realloc)(buf->handle, newSize + BUF_ALIGN_MASK);
- if (ubase == NULL) {
- return GL_FALSE;
- }
- } else {
- ubase = (*glPriv->malloc)(newSize + BUF_ALIGN_MASK);
- if (ubase == NULL) {
- return GL_FALSE;
- }
- }
- buf->size = newSize;
-
- buf->handle = ubase;
- buf->base = (void *)(((size_t)ubase + BUF_ALIGN_MASK) &
- (unsigned int) ~BUF_ALIGN_MASK);
- assert(((size_t)buf->base % BUF_ALIGN) == 0);
- }
-
- buf->width = width;
- buf->height = height;
- buf->byteWidth = alignedWidth * buf->elementSize;
- buf->outerWidth = alignedWidth;
-
- return GL_TRUE;
-}
-
-static void
-Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
-}
-
-static void
-Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
-}
-
-static void
-Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
- if (buf->handle) {
- (*glPriv->free)(buf->handle);
- buf->handle = NULL;
- }
-}
-
-
-void
-__glXInitMem(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv, GLint bits)
-{
- buf->width = buf->height = 0; /* to be filled during Update */
- buf->depth = bits;
- buf->size = 0;
- buf->handle = buf->base = NULL; /* to be filled during Update */
- buf->byteWidth = 0;
- buf->elementSize = ((bits - 1) / 8) + 1;
- buf->elementSizeLog2 = __glFloorLog2(buf->elementSize);
-
- buf->resize = Resize;
- buf->lock = Lock;
- buf->unlock = Unlock;
- buf->fill = NULL;
- buf->free = Free;
-}
diff --git a/GL/glx/glxmem.h b/GL/glx/glxmem.h
deleted file mode 100644
index 06720dfdf..000000000
--- a/GL/glx/glxmem.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $XFree86$ */
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _glxmem_h_
-#define _glxmem_h_
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-extern void __glXInitMem(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
- GLint bits);
-
-#endif /* _glxmem_h_ */
-
diff --git a/GL/glx/glxpix.c b/GL/glx/glxpix.c
deleted file mode 100644
index 98c033c98..000000000
--- a/GL/glx/glxpix.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/glx/glxpix.c,v 1.3 2000/09/26 15:57:02 tsi Exp $ */
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-/*
-** An implementation of a glx pixmap buffer
-*/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "glxserver.h"
-#include "glxutil.h"
-#include "glxpix.h"
-
-#include <gcstruct.h>
-
-/* don't want to include glmath.h */
-extern GLuint __glFloorLog2(GLuint);
-
-typedef struct __GLPixBufferInfoRec {
- GCPtr pGC;
-} __GLPixBufferInfo;
-
-/* ---------------------------------------------------------- */
-
-static GLboolean
-Resize(__GLdrawableBuffer *buf,
- GLint x, GLint y, GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv, GLuint bufferMask)
-{
- buf->width = width;
- buf->height = width;
- buf->byteWidth = width * buf->elementSize;
- buf->outerWidth = width;
-
- return GL_TRUE;
-}
-
-static void
-Lock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
-}
-
-static void
-Unlock(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
-}
-
-static void
-Free(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv)
-{
- __GLPixBufferInfo *bufferInfo;
-
- if (LookupIDByType((XID)(long)buf->handle, __glXPixmapRes)) {
- FreeResource((XID)(long)buf->handle, FALSE);
- buf->handle = NULL;
- }
-
- bufferInfo = (__GLPixBufferInfo *) buf->other;
-
- if (bufferInfo->pGC) {
- FreeScratchGC(bufferInfo->pGC);
- }
-
- __glXFree(bufferInfo);
- buf->other = NULL;
-}
-
-void
-__glXInitPix(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
- GLint bits, XID glxpixmapId, __GLXpixmap *pGlxPixmap)
-{
- __GLPixBufferInfo *bufferInfo;
-
- buf->width = buf->height = 0; /* to be filled during Update */
- buf->depth = bits;
- buf->size = 0;
- buf->base = NULL;
- buf->byteWidth = 0;
- buf->elementSize = ((bits-1) / 8) + 1;
- buf->elementSizeLog2 = __glFloorLog2(buf->elementSize);
-
- buf->handle = (void *)(long) glxpixmapId;
- pGlxPixmap->refcnt++;
-
- buf->resize = Resize;
- buf->lock = Lock;
- buf->unlock = Unlock;
- buf->fill = NULL;
- buf->free = Free;
-
- /* allocate local information */
- bufferInfo = (__GLPixBufferInfo *) __glXMalloc(sizeof(__GLPixBufferInfo));
- buf->other = (void *) bufferInfo;
-
- bufferInfo->pGC = CreateScratchGC(pGlxPixmap->pDraw->pScreen,
- pGlxPixmap->pDraw->depth);
-}
diff --git a/GL/glx/glxpix.h b/GL/glx/glxpix.h
deleted file mode 100644
index 4b16352b4..000000000
--- a/GL/glx/glxpix.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $XFree86$ */
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef _glxpix_h_
-#define _glxpix_h_
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: The application programming interfaces
-** established by SGI in conjunction with the Original Code are The
-** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
-** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
-** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
-** Window System(R) (Version 1.3), released October 19, 1998. This software
-** was created using the OpenGL(R) version 1.2.1 Sample Implementation
-** published by SGI, but has not been independently verified as being
-** compliant with the OpenGL(R) version 1.2.1 Specification.
-**
-*/
-
-extern void __glXInitPix(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
- GLint bits, XID glxpixmapId, __GLXpixmap *pGlxPixmap);
-
-#endif /* _glxpix_h_ */
-
diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c
index ffe1935e3..aa727a981 100644
--- a/GL/glx/glxscreens.c
+++ b/GL/glx/glxscreens.c
@@ -38,12 +38,9 @@
#include <dix-config.h>
#endif
-#ifndef IN_MODULE
#include <string.h>
-#include <signal.h>
-#endif
-
#include <windowstr.h>
+#include <os.h>
#include "glxserver.h"
#include "glxutil.h"
@@ -130,6 +127,7 @@ static char GLXServerExtensions[] =
"GLX_EXT_visual_info "
"GLX_EXT_visual_rating "
"GLX_EXT_import_context "
+ "GLX_EXT_texture_from_pixmap "
"GLX_OML_swap_method "
"GLX_SGI_make_current_read "
#ifndef __DARWIN__
@@ -140,75 +138,17 @@ static char GLXServerExtensions[] =
"GLX_SGIX_fbconfig "
;
-/*
- * __glDDXScreenInfo comes from GLcore, so we can't resolve this symbol at
- * module open time. Leave a placeholder, and fill this in when we first
- * need it (in __glXScreenInit). XXX Why make this an array?
- */
-static __GLXscreenInfo *__glXScreens[] = {
- NULL /* &__glDDXScreenInfo */ ,
-};
-
-static GLint __glXNumStaticScreens =
- (sizeof __glXScreens / sizeof __glXScreens[0]);
-
-__GLXscreenInfo *__glXActiveScreens;
-GLint __glXNumActiveScreens;
+__GLXscreen **__glXActiveScreens;
__GLXSwapBarrierExtensionFuncs *__glXSwapBarrierFuncs = NULL;
static int __glXNumSwapBarrierFuncs = 0;
__GLXHyperpipeExtensionFuncs *__glXHyperpipeFuncs = NULL;
static int __glXNumHyperpipeFuncs = 0;
-
-RESTYPE __glXDrawableRes;
-
-__GLXscreenInfo *__glXgetActiveScreen(int num) {
- return &__glXActiveScreens[num];
+__GLXscreen *__glXgetActiveScreen(int num) {
+ return __glXActiveScreens[num];
}
-/*
-** Destroy routine that gets called when a drawable is freed. A drawable
-** contains the ancillary buffers needed for rendering.
-*/
-static Bool DrawableGone(__GLXdrawablePrivate *glxPriv, XID xid)
-{
- __GLXcontext *cx, *cx1;
-
- /*
- ** Use glxPriv->type to figure out what kind of drawable this is. Don't
- ** use glxPriv->pDraw->type because by the time this routine is called,
- ** the pDraw might already have been freed.
- */
- if (glxPriv->type == DRAWABLE_WINDOW) {
- /*
- ** When a window is destroyed, notify all context bound to
- ** it, that there are no longer bound to anything.
- */
- for (cx = glxPriv->drawGlxc; cx; cx = cx1) {
- cx1 = cx->nextDrawPriv;
- cx->pendingState |= __GLX_PENDING_DESTROY;
- }
-
- for (cx = glxPriv->readGlxc; cx; cx = cx1) {
- cx1 = cx->nextReadPriv;
- cx->pendingState |= __GLX_PENDING_DESTROY;
- }
- }
-
- /*
- ** set the size to 0, so that context that may still be using this
- ** drawable not do anything harmful
- */
- glxPriv->xorigin = 0;
- glxPriv->yorigin = 0;
- glxPriv->width = 0;
- glxPriv->height = 0;
-
- __glXUnrefDrawablePrivate(glxPriv);
-
- return True;
-}
/*
** This hook gets called when a window moves or changes size.
@@ -217,7 +157,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
{
ScreenPtr pScreen;
__GLXcontext *glxc;
- __GLXdrawablePrivate *glxPriv;
+ __GLXdrawable *glxPriv;
Bool ret;
/*
@@ -225,7 +165,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
*/
pScreen = pWin->drawable.pScreen;
pScreen->PositionWindow =
- __glXActiveScreens[pScreen->myNum].WrappedPositionWindow;
+ __glXActiveScreens[pScreen->myNum]->WrappedPositionWindow;
ret = (*pScreen->PositionWindow)(pWin, x, y);
pScreen->PositionWindow = PositionWindow;
@@ -233,8 +173,8 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
** Tell all contexts rendering into this window that the window size
** has changed.
*/
- glxPriv = (__GLXdrawablePrivate *) LookupIDByType(pWin->drawable.id,
- __glXDrawableRes);
+ glxPriv = (__GLXdrawable *) LookupIDByType(pWin->drawable.id,
+ __glXDrawableRes);
if (glxPriv == NULL) {
/*
** This window is not being used by the OpenGL.
@@ -246,7 +186,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
** resize the drawable
*/
/* first change the drawable size */
- if (__glXResizeDrawableBuffers(glxPriv) == GL_FALSE) {
+ if (glxPriv->resize(glxPriv) == GL_FALSE) {
/* resize failed! */
/* XXX: what can we possibly do here? */
ret = False;
@@ -266,18 +206,6 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
}
/*
-** Wrap our own PositionWindow routine around the server's, so we can
-** be notified when a window changes size
-*/
-static void wrapPositionWindow(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
-
- __glXActiveScreens[screen].WrappedPositionWindow = pScreen->PositionWindow;
- pScreen->PositionWindow = PositionWindow;
-}
-
-/*
* If your DDX driver wants to register support for swap barriers or hyperpipe
* topology, it should call __glXHyperpipeInit() or __glXSwapBarrierInit()
* with a dispatch table of functions to handle the requests. In the XFree86
@@ -320,57 +248,80 @@ void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs)
funcs->queryMaxSwapBarriersFunc;
}
-void __glXScreenInit(GLint numscreens)
+static __GLXprovider *__glXProviderStack;
+
+void GlxPushProvider(__GLXprovider *provider)
+{
+ provider->next = __glXProviderStack;
+ __glXProviderStack = provider;
+}
+
+void __glXScreenInit(__GLXscreen *screen, ScreenPtr pScreen)
+{
+ screen->pScreen = pScreen;
+ screen->GLextensions = __glXStrdup(GLServerExtensions);
+ screen->GLXvendor = __glXStrdup(GLXServerVendorName);
+ screen->GLXversion = __glXStrdup(GLXServerVersion);
+ screen->GLXextensions = __glXStrdup(GLXServerExtensions);
+
+ screen->WrappedPositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = PositionWindow;
+
+ __glXScreenInitVisuals(screen);
+}
+
+void
+__glXScreenDestroy(__GLXscreen *screen)
{
- GLint i,j;
+ __glXFree(screen->GLXvendor);
+ __glXFree(screen->GLXversion);
+ __glXFree(screen->GLXextensions);
+ __glXFree(screen->GLextensions);
+}
- __glXScreens[0] = __glXglDDXScreenInfo(); /* from GLcore */
+void __glXInitScreens(void)
+{
+ GLint i;
+ ScreenPtr pScreen;
+ __GLXprovider *p;
+ size_t size;
/*
** This alloc has to work or else the server might as well core dump.
*/
- __glXActiveScreens =
- (__GLXscreenInfo *) __glXMalloc(sizeof(__GLXscreenInfo) * numscreens);
+ size = screenInfo.numScreens * sizeof(__GLXscreen *);
+ __glXActiveScreens =__glXMalloc(size);
+ __glXMemset(__glXActiveScreens, 0, size);
- for (i=0; i < numscreens; i++) {
- /*
- ** Probe each static screen to see which exists.
- */
- for (j=0; j < __glXNumStaticScreens; j++) {
- if ((*__glXScreens[j]->screenProbe)(i)) {
- __glXActiveScreens[i] = *__glXScreens[j];
-
- __glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals;
- __glXActiveScreens[i].GLextensions = __glXStrdup(GLServerExtensions);
- __glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName);
- __glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion);
- __glXActiveScreens[i].GLXextensions = __glXStrdup(GLXServerExtensions);
-
- __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
- wrapPositionWindow(i);
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+
+ for (p = __glXProviderStack; p != NULL; p = p->next) {
+ __glXActiveScreens[i] = p->screenProbe(pScreen);
+ if (__glXActiveScreens[i] != NULL) {
+ LogMessage(X_INFO,
+ "GLX: Initialized %s GL provider for screen %d\n",
+ p->name, i);
+ break;
}
}
}
- __glXNumActiveScreens = numscreens;
}
-void __glXScreenReset(void)
+void __glXResetScreens(void)
{
int i;
- for (i = 0; i < __glXNumActiveScreens; i++) {
- __glXFree(__glXActiveScreens[i].GLXvendor);
- __glXFree(__glXActiveScreens[i].GLXversion);
- __glXFree(__glXActiveScreens[i].GLXextensions);
- __glXFree(__glXActiveScreens[i].GLextensions);
- }
- xfree(__glXActiveScreens);
- xfree(__glXHyperpipeFuncs);
- xfree(__glXSwapBarrierFuncs);
- __glXNumHyperpipeFuncs = 0;
- __glXNumSwapBarrierFuncs = 0;
- __glXHyperpipeFuncs = NULL;
- __glXSwapBarrierFuncs = NULL;
- __glXActiveScreens = NULL;
- __glXNumActiveScreens = 0;
+ for (i = 0; i < screenInfo.numScreens; i++)
+ if (__glXActiveScreens[i])
+ __glXActiveScreens[i]->destroy(__glXActiveScreens[i]);
+
+ __glXFree(__glXActiveScreens);
+ __glXFree(__glXHyperpipeFuncs);
+ __glXFree(__glXSwapBarrierFuncs);
+ __glXNumHyperpipeFuncs = 0;
+ __glXNumSwapBarrierFuncs = 0;
+ __glXHyperpipeFuncs = NULL;
+ __glXSwapBarrierFuncs = NULL;
+ __glXActiveScreens = NULL;
}
diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h
index 2d68c8b60..8a2b2388f 100644
--- a/GL/glx/glxscreens.h
+++ b/GL/glx/glxscreens.h
@@ -51,28 +51,15 @@
** and DDX layers of the GLX server extension. The methods provide an
** interface for context management on a screen.
*/
-typedef struct {
- /*
- ** Probe the screen and see if it supports GL rendering. It will
- ** return GL_FALSE if it doesn't, GL_TRUE otherwise.
- */
- Bool (*screenProbe)(int screen);
+typedef struct __GLXscreen __GLXscreen;
+struct __GLXscreen {
+ void (*destroy)(__GLXscreen *screen);
- /*
- ** Create a context using configuration information from modes.
- ** Use imports as callbacks back to the OS. Return an opaque handle
- ** on the context (NULL if failure).
- */
- __GLinterface *(*createContext)(__GLimports *imports,
- __GLcontextModes *modes,
- __GLinterface *shareGC);
+ __GLXcontext *(*createContext)(__GLXscreen *screen,
+ __GLcontextModes *modes,
+ __GLXcontext *shareContext);
- /*
- ** Create a buffer using information from glxPriv. This routine
- ** sets up any wrappers necessary to resize, swap or destroy the
- ** buffer.
- */
- void (*createBuffer)(__GLXdrawablePrivate *glxPriv);
+ ScreenPtr pScreen;
/**
* Linked list of valid context modes for this screen.
@@ -94,10 +81,13 @@ typedef struct {
*/
Bool (*WrappedPositionWindow)(WindowPtr pWin, int x, int y);
-} __GLXscreenInfo;
+};
+
+void __glXScreenInit(__GLXscreen *screen, ScreenPtr pScreen);
+void __glXScreenDestroy(__GLXscreen *screen);
-extern void __glXScreenInit(GLint);
-extern void __glXScreenReset(void);
+void __glXInitScreens(void);
+extern void __glXResetScreens(void);
#endif /* !__GLX_screens_h__ */
diff --git a/GL/glx/glxserver.h b/GL/glx/glxserver.h
index 2609b1674..2e273b970 100644
--- a/GL/glx/glxserver.h
+++ b/GL/glx/glxserver.h
@@ -53,7 +53,6 @@
#include <scrnintstr.h>
#include "GL/glx_ansic.h"
-
/*
** The X header misc.h defines these math functions.
*/
@@ -66,7 +65,8 @@
#include <GL/glxint.h>
/* For glxscreens.h */
-typedef struct __GLXdrawablePrivateRec __GLXdrawablePrivate;
+typedef struct __GLXdrawable __GLXdrawable;
+typedef struct __GLXcontext __GLXcontext;
#include "glxscreens.h"
#include "glxdrawable.h"
@@ -91,15 +91,19 @@ typedef XID GLXContextID;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
-typedef struct __GLXcontextRec *GLXContext;
typedef struct __GLXclientStateRec __GLXclientState;
-extern __GLXscreenInfo *__glXActiveScreens;
+extern __GLXscreen **__glXActiveScreens;
extern GLint __glXNumActiveScreens;
-extern __GLXscreenInfo *__glXgetActiveScreen(int num);
+extern __GLXscreen *__glXgetActiveScreen(int num);
/************************************************************************/
+void GlxSetVisualConfigs(int nconfigs,
+ __GLXvisualConfig *configs, void **privates);
+
+void __glXScreenInitVisuals(__GLXscreen *screen);
+
/*
** The last context used (from the server's persective) is cached.
*/
@@ -116,6 +120,20 @@ extern __GLXcontext *__glXForceCurrent(__GLXclientState*, GLXContextTag, int*);
/************************************************************************/
+typedef struct __GLXprovider __GLXprovider;
+struct __GLXprovider {
+ __GLXscreen *(*screenProbe)(ScreenPtr pScreen);
+ const char *name;
+ __GLXprovider *next;
+};
+
+void GlxPushProvider(__GLXprovider *provider);
+
+void __glXsetEnterLeaveServerFuncs(void (*enter)(void),
+ void (*leave)(void));
+void __glXenterServer(void);
+void __glXleaveServer(void);
+
/*
** State kept per client.
*/
@@ -214,6 +232,8 @@ extern void __glXSwapQueryVersionReply(ClientPtr client,
extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client,
xGLXQueryContextInfoEXTReply *reply,
int *buf);
+extern void __glXSwapGetDrawableAttributesReply(ClientPtr client,
+ xGLXGetDrawableAttributesReply *reply, CARD32 *buf);
extern void glxSwapQueryExtensionsStringReply(ClientPtr client,
xGLXQueryExtensionsStringReply *reply, char *buf);
extern void glxSwapQueryServerStringReply(ClientPtr client,
diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c
index 25586433f..8937d12aa 100644
--- a/GL/glx/glxutil.c
+++ b/GL/glx/glxutil.c
@@ -48,7 +48,6 @@
#include <pixmapstr.h>
#include <windowstr.h>
#include "glxutil.h"
-#include "glxbuf.h"
#include "GL/glx_ansic.h"
#include "GL/internal/glcore.h"
#include "GL/glxint.h"
@@ -56,10 +55,6 @@
/************************************************************************/
-void __glXNop(void) {}
-
-/************************************************************************/
-
/* Memory Allocation for GLX */
void *
@@ -93,7 +88,7 @@ __glXCalloc(size_t numElements, size_t elementSize)
/* XXX: handle out of memory error */
return NULL;
}
- __glXMemset(addr, 0, size);
+ memset(addr, 0, size);
return addr;
}
@@ -144,13 +139,13 @@ __glXAssociateContext(__GLXcontext *glxc)
glxc->nextDrawPriv = glxc->drawPriv->drawGlxc;
glxc->drawPriv->drawGlxc = glxc;
- __glXRefDrawablePrivate(glxc->drawPriv);
+ __glXRefDrawable(glxc->drawPriv);
glxc->nextReadPriv = glxc->readPriv->readGlxc;
glxc->readPriv->readGlxc = glxc;
- __glXRefDrawablePrivate(glxc->readPriv);
+ __glXRefDrawable(glxc->readPriv);
}
/*
@@ -173,7 +168,7 @@ __glXDeassociateContext(__GLXcontext *glxc)
prev->nextDrawPriv = curr->nextDrawPriv;
}
curr->nextDrawPriv = NULL;
- __glXUnrefDrawablePrivate(glxc->drawPriv);
+ __glXUnrefDrawable(glxc->drawPriv);
break;
}
}
@@ -191,319 +186,72 @@ __glXDeassociateContext(__GLXcontext *glxc)
prev->nextReadPriv = curr->nextReadPriv;
}
curr->nextReadPriv = NULL;
- __glXUnrefDrawablePrivate(glxc->readPriv);
+ __glXUnrefDrawable(glxc->readPriv);
break;
}
}
}
-/************************************************************************/
-
-void
-__glXGetDrawableSize(__GLdrawablePrivate *glPriv,
- GLint *x, GLint *y, GLuint *width, GLuint *height)
-{
- __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
-
- if (glxPriv) {
- *x = glxPriv->xorigin;
- *y = glxPriv->yorigin;
- *width = glxPriv->width;
- *height = glxPriv->height;
- } else {
- *x = *y = *width = *height = 0;
- }
-}
-
-GLboolean
-__glXResizeDrawable(__GLdrawablePrivate *glPriv)
-{
- /* nothing to be done here */
- return GL_TRUE;
-}
-
-
-/*****************************************************************************/
-/* accessing the drawable private */
-
-static void
-LockDP(__GLdrawablePrivate *glPriv, __GLcontext *gc)
-{
- __GLinterface *glci = (__GLinterface *) gc;
- __GLXcontext *glxc = (__GLXcontext *) glci->imports.other;
-
- /* quick exit test */
- if ((glxc->pendingState &
- (__GLX_PENDING_RESIZE |
- __GLX_PENDING_DESTROY |
- __GLX_PENDING_SWAP)) == 0x0)
- return;
-
- /* some pending state. Deal with it */
- if (glxc->pendingState & __GLX_PENDING_RESIZE) {
- glxc->pendingState &= ~__GLX_PENDING_RESIZE;
-
- (*glci->exports.notifyResize)(gc);
- assert((glxc->pendingState & __GLX_PENDING_RESIZE) == 0x0);
- }
- if (glxc->pendingState & __GLX_PENDING_DESTROY) {
- glxc->pendingState &= ~__GLX_PENDING_DESTROY;
-
- assert(glxc->drawPriv->xorigin == 0);
- assert(glxc->drawPriv->yorigin == 0);
- assert(glxc->drawPriv->width == 0);
- assert(glxc->drawPriv->height == 0);
- assert(glxc->readPriv->xorigin == 0);
- assert(glxc->readPriv->yorigin == 0);
- assert(glxc->readPriv->width == 0);
- assert(glxc->readPriv->height == 0);
- (*glci->exports.notifyDestroy)(gc);
- __glXDeassociateContext(glxc);
- assert((glxc->pendingState & __GLX_PENDING_DESTROY) == 0x0);
- }
- if (glxc->pendingState & __GLX_PENDING_SWAP) {
-
- glxc->pendingState &= ~__GLX_PENDING_SWAP;
-
- (*glci->exports.notifySwapBuffers)(gc);
- assert((glxc->pendingState & __GLX_PENDING_SWAP) == 0x0);
- }
-}
-
-static void
-UnlockDP(__GLdrawablePrivate *glPriv)
-{
-}
-
/*****************************************************************************/
/* Drawable private stuff */
void
-__glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv)
+__glXRefDrawable(__GLXdrawable *glxPriv)
{
glxPriv->refCount++;
}
void
-__glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv)
+__glXUnrefDrawable(__GLXdrawable *glxPriv)
{
glxPriv->refCount--;
if (glxPriv->refCount == 0) {
- __glXDestroyDrawablePrivate(glxPriv);
+ /* remove the drawable from the drawable list */
+ FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE);
+ glxPriv->destroy(glxPriv);
}
}
-__GLXdrawablePrivate *
-__glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId,
- __GLcontextModes *modes)
+GLboolean
+__glXDrawableInit(__GLXdrawable *drawable,
+ __GLXcontext *ctx, DrawablePtr pDraw, XID drawId)
{
- __GLXdrawablePrivate *glxPriv;
- __GLdrawablePrivate *glPriv;
- __GLXscreenInfo *pGlxScreen;
-
- glxPriv = (__GLXdrawablePrivate *) __glXMalloc(sizeof(*glxPriv));
- __glXMemset(glxPriv, 0, sizeof(__GLXdrawablePrivate));
-
- glxPriv->type = pDraw->type;
- glxPriv->pDraw = pDraw;
- glxPriv->drawId = drawId;
+ drawable->type = pDraw->type;
+ drawable->pDraw = pDraw;
+ drawable->drawId = drawId;
+ drawable->refCount = 1;
/* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */
- glxPriv->pGlxPixmap = (__GLXpixmap *)
+ drawable->pGlxPixmap = (__GLXpixmap *)
LookupIDByType(drawId, __glXPixmapRes);
- /* since we are creating the drawablePrivate, drawId should be new */
- if (!AddResource(drawId, __glXDrawableRes, glxPriv)) {
- /* oops! */
- __glXFree(glxPriv);
- return NULL;
- }
-
- /* fill up glPriv */
- glPriv = &glxPriv->glPriv;
- glPriv->modes = (__GLcontextModes *) __glXMalloc(sizeof(__GLcontextModes));
- *glPriv->modes = *modes;
- glPriv->malloc = __glXMalloc;
- glPriv->calloc = __glXCalloc;
- glPriv->realloc = __glXRealloc;
- glPriv->free = __glXFree;
- glPriv->addSwapRect = NULL;
- glPriv->setClipRect = (void (*)(__GLdrawablePrivate *, GLint, GLint, GLsizei, GLsizei)) __glXNop;
- glPriv->lockDP = LockDP;
- glPriv->unlockDP = UnlockDP;
- glPriv->getDrawableSize = __glXGetDrawableSize;
- glPriv->resize = __glXResizeDrawable;
- glPriv->other = glxPriv;
-
- /* allocate a one-rect ownership region */
- glPriv->ownershipRegion.rects =
- (__GLregionRect *)__glXCalloc(1, sizeof(__GLregionRect));
- glPriv->ownershipRegion.numRects = 1;
-
- glxPriv->freeBuffers = __glXFreeBuffers;
- glxPriv->updatePalette = (void (*)(__GLXdrawablePrivate *)) __glXNop;
-
- pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
-
- if (glxPriv->type == DRAWABLE_WINDOW) {
- VisualID vid = wVisual((WindowPtr)pDraw);
-
- glxPriv->modes = _gl_context_modes_find_visual( pGlxScreen->modes, vid );
- __glXFBInitDrawable(glxPriv, modes);
- } else {
- glxPriv->modes = glxPriv->pGlxPixmap->modes;
- __glXPixInitDrawable(glxPriv, modes);
- }
-
- /* initialize the core's private buffer information */
- (*pGlxScreen->createBuffer)(glxPriv);
-
- return glxPriv;
-}
-GLboolean
-__glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv)
-{
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
-
- /* remove the drawable from the drawable list */
- FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE);
-
- /* Have the core free any memory it may have attached to the drawable */
- if (glPriv->freePrivate) {
- (*glPriv->freePrivate)(glPriv);
- }
-
- /* Free any framebuffer memory attached to the drawable */
- if (glxPriv->freeBuffers) {
- (*glxPriv->freeBuffers)(glxPriv);
+ /* since we are creating the drawablePrivate, drawId should be new */
+ if (!AddResource(drawId, __glXDrawableRes, drawable)) {
+ return GL_FALSE;
}
- /* Free the drawable Private */
- __glXFree(glxPriv->glPriv.modes);
- __glXFree(glxPriv->glPriv.ownershipRegion.rects);
- __glXFree(glxPriv);
-
return GL_TRUE;
}
-__GLXdrawablePrivate *
-__glXFindDrawablePrivate(XID drawId)
+__GLXdrawable *
+__glXFindDrawable(XID drawId)
{
- __GLXdrawablePrivate *glxPriv;
+ __GLXdrawable *glxPriv;
- glxPriv = (__GLXdrawablePrivate *)LookupIDByType(drawId, __glXDrawableRes);
+ glxPriv = (__GLXdrawable *)LookupIDByType(drawId, __glXDrawableRes);
return glxPriv;
}
-__GLXdrawablePrivate *
-__glXGetDrawablePrivate(DrawablePtr pDraw, XID drawId,
- __GLcontextModes *modes)
+__GLXdrawable *
+__glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId)
{
- __GLXdrawablePrivate *glxPriv;
+ __GLXdrawable *glxPriv;
- glxPriv = __glXFindDrawablePrivate(drawId);
+ glxPriv = __glXFindDrawable(drawId);
- if (glxPriv == NULL) {
- glxPriv = __glXCreateDrawablePrivate(pDraw, drawId, modes);
- if (glxPriv) {
- __glXRefDrawablePrivate(glxPriv);
- }
- }
+ if (glxPriv == NULL)
+ glxPriv = ctx->createDrawable(ctx, pDraw, drawId);
return glxPriv;
}
-
-void
-__glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv)
-{
- if (glxPriv) {
- if (glxPriv->pDraw) {
- glxPriv->xorigin = glxPriv->pDraw->x;
- glxPriv->yorigin = glxPriv->pDraw->y;
- glxPriv->width = glxPriv->pDraw->width;
- glxPriv->height = glxPriv->pDraw->height;
- }
- }
-}
-
-/*
-** resize/move the drawable. Called during the actual resize callback
-** to update the drawable side of the buffers
-*/
-GLboolean
-__glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv)
-{
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
- GLint x, y;
- GLuint w, h;
-#if defined(__GL_ALIGNED_BUFFERS)
- GLint xAlignment, yAlignment;
- GLint xOffset, yOffset;
- GLint xStart, xEnd;
- GLint yStart, yEnd;
- GLuint xAlignedMask, yAlignedMask;
-#endif
- GLboolean status = GL_TRUE;
-
- __glXCacheDrawableSize(glxPriv);
-
- w = glxPriv->width;
- h = glxPriv->height;
- x = glxPriv->xorigin;
- y = glxPriv->yorigin;
-
-#if defined(__GL_ALIGNED_BUFFERS)
- xAlignment = glPriv->xAlignment;
- yAlignment = glPriv->yAlignment;
-
- xOffset = x & (xAlignment-1);
- yOffset = y & (yAlignment-1);
-
- xAlignedMask = ~(xAlignment-1);
- yAlignedMask = ~(yAlignment-1);
-
- xStart = x; xEnd = x+w;
- yStart = y; yEnd = y+h;
-
- xStart &= xAlignedMask;
- if (xEnd & ~xAlignedMask) {
- xEnd = (xEnd&xAlignedMask) + xAlignment;
- }
- yStart &= yAlignedMask;
- if (yEnd & ~yAlignedMask) {
- yEnd = (yEnd&yAlignedMask) + yAlignment;
- }
-
- x = xStart; y = yStart;
- w = xEnd-xStart; h = yEnd-yStart;
-#endif
-
- if ((x != glPriv->xOrigin) ||
- (y != glPriv->yOrigin) ||
-#if defined(__GL_ALIGNED_BUFFERS)
- (xOffset != glPriv->xOffset) ||
- (yOffset != glPriv->yOffset) ||
-#endif
- (w != glPriv->width) ||
- (h != glPriv->height) ||
- (!w && !h)) {
- /* set up the glPriv info */
- glPriv->width = w;
- glPriv->height = h;
- glPriv->xOrigin = x;
- glPriv->yOrigin = y;
-#if defined(__GL_ALIGNED_BUFFERS)
- glPriv->xOffset = xOffset;
- glPriv->yOffset = yOffset;
-#endif
-
- /* notify the buffers */
- status = __glXResizeBuffers(glPriv, x, y, w, h);
- }
-
- return status;
-}
-
-/************************************************************************/
-
diff --git a/GL/glx/glxutil.h b/GL/glx/glxutil.h
index 2c3090a46..07384bf76 100644
--- a/GL/glx/glxutil.h
+++ b/GL/glx/glxutil.h
@@ -58,20 +58,23 @@ extern void __glXGetDrawableSize(__GLdrawablePrivate *glPriv,
GLint *x, GLint *y,
GLuint *width, GLuint *height);
extern GLboolean __glXResizeDrawable(__GLdrawablePrivate *glPriv);
-extern GLboolean __glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv);
+extern GLboolean __glXResizeDrawableBuffers(__GLXdrawable *glxPriv);
/* drawable management */
-extern void __glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv);
-extern void __glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv);
-extern __GLXdrawablePrivate *__glXCreateDrawablePrivate(DrawablePtr pDraw,
- XID glxpixmapId,
- __GLcontextModes *modes);
-extern GLboolean __glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv);
-extern __GLXdrawablePrivate *__glXFindDrawablePrivate(XID glxpixmapId);
-extern __GLXdrawablePrivate *__glXGetDrawablePrivate(DrawablePtr pDraw,
- XID glxpixmapId,
- __GLcontextModes *modes);
-extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv);
+extern void __glXRefDrawable(__GLXdrawable *glxPriv);
+extern void __glXUnrefDrawable(__GLXdrawable *glxPriv);
+
+extern __GLXdrawable *__glXCreateDrawable(__GLXcontext *ctx,
+ DrawablePtr pDraw,
+ XID glxpixmapId);
+extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, __GLXcontext *ctx,
+ DrawablePtr pDraw, XID drawID);
+extern GLboolean __glXDestroyDrawable(__GLXdrawable *glxPriv);
+extern __GLXdrawable *__glXFindDrawable(XID glxpixmapId);
+extern __GLXdrawable *__glXGetDrawable(__GLXcontext *ctx,
+ DrawablePtr pDraw,
+ XID glxpixmapId);
+extern void __glXCacheDrawableSize(__GLXdrawable *glxPriv);
/* context helper routines */
extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag);
diff --git a/GL/glx/glxvisuals.c b/GL/glx/glxvisuals.c
new file mode 100644
index 000000000..9b5839ce9
--- /dev/null
+++ b/GL/glx/glxvisuals.c
@@ -0,0 +1,517 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ * (C) Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * RED HAT, INC, OR PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ * Kristian Høgsberg <krh@redhat.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+#include <regionstr.h>
+#include <resource.h>
+#include <GL/gl.h>
+#include <GL/glxint.h>
+#include <GL/glxtokens.h>
+#include <GL/internal/glcore.h>
+#include <scrnintstr.h>
+#include <config.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxext.h>
+#include <glxutil.h>
+#include <micmap.h>
+
+void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+
+#include "glcontextmodes.h"
+
+struct ScreenVisualsRec {
+ int num_vis;
+ void *private;
+ __GLcontextModes *modes;
+};
+typedef struct ScreenVisualsRec ScreenVisuals;
+
+static ScreenVisuals screenVisuals[MAXSCREENS];
+
+static int numConfigs = 0;
+static __GLXvisualConfig *visualConfigs = NULL;
+static void **visualPrivates = NULL;
+
+static int count_bits(unsigned int n)
+{
+ int bits = 0;
+
+ while (n > 0) {
+ if (n & 1) bits++;
+ n >>= 1;
+ }
+ return bits;
+}
+
+/*
+ * In the case the driver defines no GLX visuals we'll use these.
+ * Note that for TrueColor and DirectColor visuals, bufferSize is the
+ * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
+ * than the nplanes/rootDepth of the server's X11 visuals
+ */
+#define NUM_FALLBACK_CONFIGS 5
+static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
+ /* [0] = RGB, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [1] = RGB, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 16, 16, 16, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
+ {
+ -1, /* vid */
+ -1, /* class */
+ True, /* rgba */
+ -1, -1, -1, 8, /* rgba sizes */
+ -1, -1, -1, -1, /* rgba masks */
+ 16, 16, 16, 16, /* rgba accum sizes */
+ False, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 8, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+ /* [4] = CI, double buffered, Z */
+ {
+ -1, /* vid */
+ -1, /* class */
+ False, /* rgba? (false = color index) */
+ -1, -1, -1, 0, /* rgba sizes */
+ -1, -1, -1, 0, /* rgba masks */
+ 0, 0, 0, 0, /* rgba accum sizes */
+ True, /* doubleBuffer */
+ False, /* stereo */
+ -1, /* bufferSize */
+ 16, /* depthSize */
+ 0, /* stencilSize */
+ 0, /* auxBuffers */
+ 0, /* level */
+ GLX_NONE, /* visualRating */
+ GLX_NONE, /* transparentPixel */
+ 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
+ 0 /* transparentIndex */
+ },
+};
+
+
+static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
+ VisualID *defaultVisp,
+ int ndepth, DepthPtr pdepth,
+ int rootDepth)
+{
+ int numRGBconfigs;
+ int numCIconfigs;
+ int numVisuals = *nvisualp;
+ int numNewVisuals;
+ int numNewConfigs;
+ VisualPtr pVisual = *visualp;
+ VisualPtr pVisualNew = NULL;
+ VisualID *orig_vid = NULL;
+ __GLcontextModes *modes;
+ __GLXvisualConfig *pNewVisualConfigs = NULL;
+ void **glXVisualPriv;
+ void **pNewVisualPriv;
+ int found_default;
+ int i, j, k;
+
+ if (numConfigs > 0)
+ numNewConfigs = numConfigs;
+ else
+ numNewConfigs = NUM_FALLBACK_CONFIGS;
+
+ /* Alloc space for the list of new GLX visuals */
+ pNewVisualConfigs = (__GLXvisualConfig *)
+ __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
+ if (!pNewVisualConfigs) {
+ return FALSE;
+ }
+
+ /* Alloc space for the list of new GLX visual privates */
+ pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
+ if (!pNewVisualPriv) {
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /*
+ ** If SetVisualConfigs was not called, then use default GLX
+ ** visual configs.
+ */
+ if (numConfigs == 0) {
+ memcpy(pNewVisualConfigs, FallbackConfigs,
+ NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
+ memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
+ }
+ else {
+ /* copy driver's visual config info */
+ for (i = 0; i < numConfigs; i++) {
+ pNewVisualConfigs[i] = visualConfigs[i];
+ pNewVisualPriv[i] = visualPrivates[i];
+ }
+ }
+
+ /* Count the number of RGB and CI visual configs */
+ numRGBconfigs = 0;
+ numCIconfigs = 0;
+ for (i = 0; i < numNewConfigs; i++) {
+ if (pNewVisualConfigs[i].rgba)
+ numRGBconfigs++;
+ else
+ numCIconfigs++;
+ }
+
+ /* Count the total number of visuals to compute */
+ numNewVisuals = 0;
+ for (i = 0; i < numVisuals; i++) {
+ numNewVisuals +=
+ (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
+ ? numRGBconfigs : numCIconfigs;
+ }
+
+ /* Reset variables for use with the next screen/driver's visual configs */
+ visualConfigs = NULL;
+ numConfigs = 0;
+
+ /* Alloc temp space for the list of orig VisualIDs for each new visual */
+ orig_vid = (VisualID *) __glXMalloc(numNewVisuals * sizeof(VisualID));
+ if (!orig_vid) {
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisuals */
+ modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
+ if (modes == NULL) {
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the list of glXVisualPrivates */
+ glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
+ if (!glXVisualPriv) {
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Alloc space for the new list of the X server's visuals */
+ pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
+ if (!pVisualNew) {
+ __glXFree(glXVisualPriv);
+ _gl_context_modes_destroy( modes );
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+ return FALSE;
+ }
+
+ /* Initialize the new visuals */
+ found_default = FALSE;
+ screenVisuals[screenInfo.numScreens-1].modes = modes;
+ for (i = j = 0; i < numVisuals; i++) {
+ int is_rgb = (pVisual[i].class == TrueColor ||
+ pVisual[i].class == DirectColor);
+
+ for (k = 0; k < numNewConfigs; k++) {
+ if (pNewVisualConfigs[k].rgba != is_rgb)
+ continue;
+
+ assert( modes != NULL );
+
+ /* Initialize the new visual */
+ pVisualNew[j] = pVisual[i];
+ pVisualNew[j].vid = FakeClientID(0);
+
+ /* Check for the default visual */
+ if (!found_default && pVisual[i].vid == *defaultVisp) {
+ *defaultVisp = pVisualNew[j].vid;
+ found_default = TRUE;
+ }
+
+ /* Save the old VisualID */
+ orig_vid[j] = pVisual[i].vid;
+
+ /* Initialize the glXVisual */
+ _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
+ modes->visualID = pVisualNew[j].vid;
+ if (modes->fbconfigID == GLX_DONT_CARE)
+ modes->fbconfigID = modes->visualID;
+
+ /*
+ * If the class is -1, then assume the X visual information
+ * is identical to what GLX needs, and take them from the X
+ * visual. NOTE: if class != -1, then all other fields MUST
+ * be initialized.
+ */
+ if (modes->visualType == GLX_NONE) {
+ modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
+ modes->redBits = count_bits(pVisual[i].redMask);
+ modes->greenBits = count_bits(pVisual[i].greenMask);
+ modes->blueBits = count_bits(pVisual[i].blueMask);
+ modes->alphaBits = modes->alphaBits;
+ modes->redMask = pVisual[i].redMask;
+ modes->greenMask = pVisual[i].greenMask;
+ modes->blueMask = pVisual[i].blueMask;
+ modes->alphaMask = modes->alphaMask;
+ modes->rgbBits = (is_rgb)
+ ? (modes->redBits + modes->greenBits +
+ modes->blueBits + modes->alphaBits)
+ : rootDepth;
+ }
+
+ /* Save the device-dependent private for this visual */
+ glXVisualPriv[j] = pNewVisualPriv[k];
+
+ j++;
+ modes = modes->next;
+ }
+ }
+
+ assert(j <= numNewVisuals);
+
+ /* Save the GLX visuals in the screen structure */
+ screenVisuals[screenInfo.numScreens-1].num_vis = numNewVisuals;
+ screenVisuals[screenInfo.numScreens-1].private = glXVisualPriv;
+
+ /* Set up depth's VisualIDs */
+ for (i = 0; i < ndepth; i++) {
+ int numVids = 0;
+ VisualID *pVids = NULL;
+ int k, n = 0;
+
+ /* Count the new number of VisualIDs at this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ numVids++;
+
+ /* Allocate a new list of VisualIDs for this depth */
+ pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
+
+ /* Initialize the new list of VisualIDs for this depth */
+ for (j = 0; j < pdepth[i].numVids; j++)
+ for (k = 0; k < numNewVisuals; k++)
+ if (pdepth[i].vids[j] == orig_vid[k])
+ pVids[n++] = pVisualNew[k].vid;
+
+ /* Update this depth's list of VisualIDs */
+ __glXFree(pdepth[i].vids);
+ pdepth[i].vids = pVids;
+ pdepth[i].numVids = numVids;
+ }
+
+ /* Update the X server's visuals */
+ *nvisualp = numNewVisuals;
+ *visualp = pVisualNew;
+
+ /* Free the old list of the X server's visuals */
+ __glXFree(pVisual);
+
+ /* Clean up temporary allocations */
+ __glXFree(orig_vid);
+ __glXFree(pNewVisualPriv);
+ __glXFree(pNewVisualConfigs);
+
+ /* Free the private list created by DDX HW driver */
+ if (visualPrivates)
+ __glXFree(visualPrivates);
+ visualPrivates = NULL;
+
+ return TRUE;
+}
+
+void GlxSetVisualConfigs(int nconfigs,
+ __GLXvisualConfig *configs, void **privates)
+{
+ numConfigs = nconfigs;
+ visualConfigs = configs;
+ visualPrivates = privates;
+}
+
+static miInitVisualsProcPtr saveInitVisualsProc;
+
+static Bool __glXInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
+ int *nvisualp, int *ndepthp,
+ int *rootDepthp, VisualID *defaultVisp,
+ unsigned long sizes, int bitsPerRGB,
+ int preferredVis)
+{
+ Bool ret;
+
+ if (saveInitVisualsProc) {
+ ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
+ rootDepthp, defaultVisp, sizes, bitsPerRGB,
+ preferredVis);
+ if (!ret)
+ return False;
+ }
+
+ /*
+ * Setup the visuals supported by this particular screen.
+ */
+ init_visuals(nvisualp, visualp, defaultVisp,
+ *ndepthp, *depthp, *rootDepthp);
+
+
+ return True;
+}
+
+
+/************************************************************************/
+
+
+void
+GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
+{
+ saveInitVisualsProc = *initVisProc;
+ *initVisProc = __glXInitVisuals;
+}
+
+static void fixup_visuals(int screen)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen];
+ ScreenVisuals *psv = &screenVisuals[screen];
+ int j;
+ __GLcontextModes *modes;
+
+ for ( modes = psv->modes ; modes != NULL ; modes = modes->next ) {
+ const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
+ const int nplanes = (modes->rgbBits - modes->alphaBits);
+ const VisualPtr pVis = pScreen->visuals;
+
+ /* Find a visual that matches the GLX visual's class and size */
+ for (j = 0; j < pScreen->numVisuals; j++) {
+ if (pVis[j].class == vis_class &&
+ pVis[j].nplanes == nplanes) {
+
+ /* Fixup the masks */
+ modes->redMask = pVis[j].redMask;
+ modes->greenMask = pVis[j].greenMask;
+ modes->blueMask = pVis[j].blueMask;
+
+ /* Recalc the sizes */
+ modes->redBits = count_bits(modes->redMask);
+ modes->greenBits = count_bits(modes->greenMask);
+ modes->blueBits = count_bits(modes->blueMask);
+ }
+ }
+ }
+}
+
+void __glXScreenInitVisuals(__GLXscreen *screen)
+{
+ int index = screen->pScreen->myNum;
+
+ screen->modes = screenVisuals[index].modes;
+ screen->pVisualPriv = screenVisuals[index].private;
+ screen->numVisuals = screenVisuals[index].num_vis;
+ screen->numUsableVisuals = screenVisuals[index].num_vis;
+
+ /*
+ * The ordering of the rgb compenents might have been changed by the
+ * driver after mi initialized them.
+ */
+ fixup_visuals(index);
+}
diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c
index 5dd4e7c37..b185a958a 100644
--- a/GL/mesa/X/xf86glx.c
+++ b/GL/mesa/X/xf86glx.c
@@ -37,12 +37,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <dix-config.h>
#endif
+#include <string.h>
#include <regionstr.h>
#include <resource.h>
#include <GL/gl.h>
#include <GL/glxint.h>
#include <GL/glxtokens.h>
#include <scrnintstr.h>
+#include <windowstr.h>
#include <config.h>
#include <glxserver.h>
#include <glxscreens.h>
@@ -50,12 +52,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <glxcontext.h>
#include <glxext.h>
#include <glxutil.h>
-#include "xf86glxint.h"
#include "context.h"
#include "xmesaP.h"
#include <GL/xf86glx.h>
#include "context.h"
+#include "glcontextmodes.h"
+#include "os.h"
+
/*
* This define is for the glcore.h header file.
* If you add it here, then make sure you also add it in
@@ -69,489 +73,265 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <GL/internal/glcore.h>
#endif
-#include "glcontextmodes.h"
+typedef struct __GLXMESAscreen __GLXMESAscreen;
+typedef struct __GLXMESAcontext __GLXMESAcontext;
+typedef struct __GLXMESAdrawable __GLXMESAdrawable;
-/*
- * This structure is statically allocated in the __glXScreens[]
- * structure. This struct is not used anywhere other than in
- * __glXScreenInit to initialize each of the active screens
- * (__glXActiveScreens[]). Several of the fields must be initialized by
- * the screenProbe routine before they are copied to the active screens
- * struct. In particular, the contextCreate, pGlxVisual, numVisuals,
- * and numUsableVisuals fields must be initialized.
- */
-static __GLXscreenInfo __glDDXScreenInfo = {
- __MESA_screenProbe, /* Must be generic and handle all screens */
- __MESA_createContext, /* Substitute screen's createContext routine */
- __MESA_createBuffer, /* Substitute screen's createBuffer routine */
- NULL, /* Set up modes in probe */
- NULL, /* Set up pVisualPriv in probe */
- 0, /* Set up numVisuals in probe */
- 0, /* Set up numUsableVisuals in probe */
- NULL, /* GLextensions is overwritten by __glXScreenInit */
- "Vendor String", /* GLXvendor is overwritten by __glXScreenInit */
- "Version String", /* GLXversion is overwritten by __glXScreenInit */
- "Extensions String", /* GLXextensions is overwritten by __glXScreenInit */
- NULL /* WrappedPositionWindow is overwritten */
+struct __GLXMESAscreen {
+ __GLXscreen base;
+ int index;
+ XMesaVisual *xm_vis;
};
-void *__glXglDDXScreenInfo(void) {
- return &__glDDXScreenInfo;
-}
+struct __GLXMESAcontext {
+ __GLXcontext base;
+ XMesaContext xmesa;
+};
-static __GLXextensionInfo __glDDXExtensionInfo = {
- GL_CORE_MESA,
- __MESA_resetExtension,
- __MESA_initVisuals,
- __MESA_setVisualConfigs
+struct __GLXMESAdrawable {
+ __GLXdrawable base;
+ XMesaBuffer xm_buf;
};
-void *__glXglDDXExtensionInfo(void) {
- return &__glDDXExtensionInfo;
-}
+static XMesaVisual find_mesa_visual(__GLXscreen *screen, VisualID vid);
-static __MESA_screen MESAScreens[MAXSCREENS];
-static __GLcontext *MESA_CC = NULL;
-static int numConfigs = 0;
-static __GLXvisualConfig *visualConfigs = NULL;
-static void **visualPrivates = NULL;
+static void
+__glXMesaDrawableDestroy(__GLXdrawable *base)
+{
+ __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
+ XMesaDestroyBuffer(glxPriv->xm_buf);
+ xfree(glxPriv);
+}
-static int count_bits(unsigned int n)
+static GLboolean
+__glXMesaDrawableResize(__GLXdrawable *base)
{
- int bits = 0;
+ __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
- while (n > 0) {
- if (n & 1) bits++;
- n >>= 1;
- }
- return bits;
-}
+ XMesaResizeBuffers(glxPriv->xm_buf);
+ return GL_TRUE;
+}
-static XMesaVisual find_mesa_visual(int screen, VisualID vid)
+static GLboolean
+__glXMesaDrawableSwapBuffers(__GLXdrawable *base)
{
- __MESA_screen * const pMScr = &MESAScreens[screen];
- const __GLcontextModes *modes;
- unsigned i = 0;
+ __GLXMESAdrawable *glxPriv = (__GLXMESAdrawable *) base;
- for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) {
- if ( modes->visualID == vid ) {
- break;
- }
+ /* This is terrifying: XMesaSwapBuffers() ends up calling CopyArea
+ * to do the buffer swap, but this assumes that the server holds
+ * the lock and has its context visible. If another screen uses a
+ * DRI driver, that will have installed the DRI enter/leave server
+ * functions, which lifts the lock during GLX dispatch. This is
+ * why we need to re-take the lock and swap in the server context
+ * before calling XMesaSwapBuffers() here. /me shakes head. */
- i++;
- }
+ __glXenterServer();
- return (modes != NULL) ? pMScr->xm_vis[i] : NULL;
-}
+ XMesaSwapBuffers(glxPriv->xm_buf);
+ __glXleaveServer();
-/*
- * In the case the driver defines no GLX visuals we'll use these.
- * Note that for TrueColor and DirectColor visuals, bufferSize is the
- * sum of redSize, greenSize, blueSize and alphaSize, which may be larger
- * than the nplanes/rootDepth of the server's X11 visuals
- */
-#define NUM_FALLBACK_CONFIGS 5
-static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
- /* [0] = RGB, double buffered, Z */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [1] = RGB, double buffered, Z, stencil, accum */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 16, 16, 16, 0, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 8, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 8, /* rgba sizes */
- -1, -1, -1, -1, /* rgba masks */
- 16, 16, 16, 16, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 8, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
- {
- -1, /* vid */
- -1, /* class */
- True, /* rgba */
- -1, -1, -1, 8, /* rgba sizes */
- -1, -1, -1, -1, /* rgba masks */
- 16, 16, 16, 16, /* rgba accum sizes */
- False, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 8, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- /* [4] = CI, double buffered, Z */
- {
- -1, /* vid */
- -1, /* class */
- False, /* rgba? (false = color index) */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- True, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE, /* visualRating */
- GLX_NONE, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
-};
+ return GL_TRUE;
+}
-static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
- VisualID *defaultVisp,
- int ndepth, DepthPtr pdepth,
- int rootDepth)
+static __GLXdrawable *
+__glXMesaContextCreateDrawable(__GLXcontext *context,
+ DrawablePtr pDraw,
+ XID drawId)
{
- int numRGBconfigs;
- int numCIconfigs;
- int numVisuals = *nvisualp;
- int numNewVisuals;
- int numNewConfigs;
- VisualPtr pVisual = *visualp;
- VisualPtr pVisualNew = NULL;
- VisualID *orig_vid = NULL;
- __GLcontextModes *modes;
- __GLXvisualConfig *pNewVisualConfigs = NULL;
- void **glXVisualPriv;
- void **pNewVisualPriv;
- int found_default;
- int i, j, k;
-
- if (numConfigs > 0)
- numNewConfigs = numConfigs;
- else
- numNewConfigs = NUM_FALLBACK_CONFIGS;
-
- /* Alloc space for the list of new GLX visuals */
- pNewVisualConfigs = (__GLXvisualConfig *)
- __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
- if (!pNewVisualConfigs) {
- return FALSE;
- }
+ __GLXMESAdrawable *glxPriv;
+ __GLXscreen *pGlxScreen;
+ XMesaVisual xm_vis;
- /* Alloc space for the list of new GLX visual privates */
- pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
- if (!pNewVisualPriv) {
- __glXFree(pNewVisualConfigs);
- return FALSE;
- }
+ glxPriv = xalloc(sizeof *glxPriv);
+ if (glxPriv == NULL)
+ return NULL;
- /*
- ** If SetVisualConfigs was not called, then use default GLX
- ** visual configs.
- */
- if (numConfigs == 0) {
- memcpy(pNewVisualConfigs, FallbackConfigs,
- NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
- memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
- }
- else {
- /* copy driver's visual config info */
- for (i = 0; i < numConfigs; i++) {
- pNewVisualConfigs[i] = visualConfigs[i];
- pNewVisualPriv[i] = visualPrivates[i];
- }
- }
+ memset(glxPriv, 0, sizeof *glxPriv);
- /* Count the number of RGB and CI visual configs */
- numRGBconfigs = 0;
- numCIconfigs = 0;
- for (i = 0; i < numNewConfigs; i++) {
- if (pNewVisualConfigs[i].rgba)
- numRGBconfigs++;
- else
- numCIconfigs++;
+ if (!__glXDrawableInit(&glxPriv->base, context, pDraw, drawId)) {
+ xfree(glxPriv);
+ return NULL;
}
- /* Count the total number of visuals to compute */
- numNewVisuals = 0;
- for (i = 0; i < numVisuals; i++) {
- numNewVisuals +=
- (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
- ? numRGBconfigs : numCIconfigs;
- }
+ glxPriv->base.destroy = __glXMesaDrawableDestroy;
+ glxPriv->base.resize = __glXMesaDrawableResize;
+ glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers;
- /* Reset variables for use with the next screen/driver's visual configs */
- visualConfigs = NULL;
- numConfigs = 0;
+ pGlxScreen = __glXActiveScreens[pDraw->pScreen->myNum];
- /* Alloc temp space for the list of orig VisualIDs for each new visual */
- orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID));
- if (!orig_vid) {
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
- }
+ if (glxPriv->base.type == DRAWABLE_WINDOW) {
+ VisualID vid = wVisual((WindowPtr)pDraw);
- /* Alloc space for the list of glXVisuals */
- modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
- if (modes == NULL) {
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ glxPriv->base.modes = _gl_context_modes_find_visual(pGlxScreen->modes,
+ vid);
+ } else {
+ glxPriv->base.modes = glxPriv->base.pGlxPixmap->modes;
}
- /* Alloc space for the list of glXVisualPrivates */
- glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
- if (!glXVisualPriv) {
- _gl_context_modes_destroy( modes );
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ xm_vis = find_mesa_visual(pGlxScreen, glxPriv->base.modes->visualID);
+ if (xm_vis == NULL) {
+ ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+ glxPriv->base.modes->visualID);
+ xfree(glxPriv);
+ return NULL;
}
- /* Alloc space for the new list of the X server's visuals */
- pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
- if (!pVisualNew) {
- __glXFree(glXVisualPriv);
- _gl_context_modes_destroy( modes );
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
- return FALSE;
+ if (glxPriv->base.type == DRAWABLE_WINDOW) {
+ glxPriv->xm_buf = XMesaCreateWindowBuffer(xm_vis, (WindowPtr)pDraw);
+ } else {
+ glxPriv->xm_buf = XMesaCreatePixmapBuffer(xm_vis, (PixmapPtr)pDraw, 0);
}
- /* Initialize the new visuals */
- found_default = FALSE;
- MESAScreens[screenInfo.numScreens-1].modes = modes;
- for (i = j = 0; i < numVisuals; i++) {
- int is_rgb = (pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor);
-
- for (k = 0; k < numNewConfigs; k++) {
- if (pNewVisualConfigs[k].rgba != is_rgb)
- continue;
-
- assert( modes != NULL );
+ return &glxPriv->base;
+}
- /* Initialize the new visual */
- pVisualNew[j] = pVisual[i];
- pVisualNew[j].vid = FakeClientID(0);
+static void
+__glXMesaContextDestroy(__GLXcontext *baseContext)
+{
+ __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
- /* Check for the default visual */
- if (!found_default && pVisual[i].vid == *defaultVisp) {
- *defaultVisp = pVisualNew[j].vid;
- found_default = TRUE;
- }
+ XMesaDestroyContext(context->xmesa);
+ xfree(context);
+}
- /* Save the old VisualID */
- orig_vid[j] = pVisual[i].vid;
-
- /* Initialize the glXVisual */
- _gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
- modes->visualID = pVisualNew[j].vid;
-
- /*
- * If the class is -1, then assume the X visual information
- * is identical to what GLX needs, and take them from the X
- * visual. NOTE: if class != -1, then all other fields MUST
- * be initialized.
- */
- if (modes->visualType == GLX_NONE) {
- modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
- modes->redBits = count_bits(pVisual[i].redMask);
- modes->greenBits = count_bits(pVisual[i].greenMask);
- modes->blueBits = count_bits(pVisual[i].blueMask);
- modes->alphaBits = modes->alphaBits;
- modes->redMask = pVisual[i].redMask;
- modes->greenMask = pVisual[i].greenMask;
- modes->blueMask = pVisual[i].blueMask;
- modes->alphaMask = modes->alphaMask;
- modes->rgbBits = (is_rgb)
- ? (modes->redBits + modes->greenBits +
- modes->blueBits + modes->alphaBits)
- : rootDepth;
- }
+static int
+__glXMesaContextMakeCurrent(__GLXcontext *baseContext)
- /* Save the device-dependent private for this visual */
- glXVisualPriv[j] = pNewVisualPriv[k];
+{
+ __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
+ __GLXMESAdrawable *drawPriv = (__GLXMESAdrawable *) context->base.drawPriv;
+ __GLXMESAdrawable *readPriv = (__GLXMESAdrawable *) context->base.readPriv;
- j++;
- modes = modes->next;
- }
- }
+ return XMesaMakeCurrent2(context->xmesa,
+ drawPriv->xm_buf,
+ readPriv->xm_buf);
+}
- assert(j <= numNewVisuals);
-
- /* Save the GLX visuals in the screen structure */
- MESAScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- MESAScreens[screenInfo.numScreens-1].private = glXVisualPriv;
-
- /* Set up depth's VisualIDs */
- for (i = 0; i < ndepth; i++) {
- int numVids = 0;
- VisualID *pVids = NULL;
- int k, n = 0;
-
- /* Count the new number of VisualIDs at this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- numVids++;
-
- /* Allocate a new list of VisualIDs for this depth */
- pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
-
- /* Initialize the new list of VisualIDs for this depth */
- for (j = 0; j < pdepth[i].numVids; j++)
- for (k = 0; k < numNewVisuals; k++)
- if (pdepth[i].vids[j] == orig_vid[k])
- pVids[n++] = pVisualNew[k].vid;
-
- /* Update this depth's list of VisualIDs */
- __glXFree(pdepth[i].vids);
- pdepth[i].vids = pVids;
- pdepth[i].numVids = numVids;
- }
+static int
+__glXMesaContextLoseCurrent(__GLXcontext *baseContext)
+{
+ __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
- /* Update the X server's visuals */
- *nvisualp = numNewVisuals;
- *visualp = pVisualNew;
+ return XMesaLoseCurrent(context->xmesa);
+}
- /* Free the old list of the X server's visuals */
- __glXFree(pVisual);
+static int
+__glXMesaContextCopy(__GLXcontext *baseDst,
+ __GLXcontext *baseSrc,
+ unsigned long mask)
+{
+ __GLXMESAcontext *dst = (__GLXMESAcontext *) baseDst;
+ __GLXMESAcontext *src = (__GLXMESAcontext *) baseSrc;
- /* Clean up temporary allocations */
- __glXFree(orig_vid);
- __glXFree(pNewVisualPriv);
- __glXFree(pNewVisualConfigs);
+ _mesa_copy_context(&src->xmesa->mesa, &dst->xmesa->mesa, mask);
+ return GL_TRUE;
+}
- /* Free the private list created by DDX HW driver */
- if (visualPrivates)
- xfree(visualPrivates);
- visualPrivates = NULL;
+static int
+__glXMesaContextForceCurrent(__GLXcontext *baseContext)
+{
+ __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext;
- return TRUE;
+ return XMesaForceCurrent(context->xmesa);
}
-void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates)
+static __GLXcontext *
+__glXMesaScreenCreateContext(__GLXscreen *screen,
+ __GLcontextModes *modes,
+ __GLXcontext *baseShareContext)
{
- numConfigs = nconfigs;
- visualConfigs = configs;
- visualPrivates = privates;
+ __GLXMESAcontext *context;
+ __GLXMESAcontext *shareContext = (__GLXMESAcontext *) baseShareContext;
+ XMesaVisual xm_vis;
+ XMesaContext xm_share;
+
+ context = xalloc (sizeof (__GLXMESAcontext));
+ if (context == NULL)
+ return NULL;
+
+ memset(context, 0, sizeof *context);
+
+ context->base.pGlxScreen = screen;
+ context->base.modes = modes;
+
+ context->base.destroy = __glXMesaContextDestroy;
+ context->base.makeCurrent = __glXMesaContextMakeCurrent;
+ context->base.loseCurrent = __glXMesaContextLoseCurrent;
+ context->base.copy = __glXMesaContextCopy;
+ context->base.forceCurrent = __glXMesaContextForceCurrent;
+ context->base.createDrawable = __glXMesaContextCreateDrawable;
+
+ xm_vis = find_mesa_visual(screen, modes->visualID);
+ if (!xm_vis) {
+ ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
+ modes->visualID);
+ xfree(context);
+ return NULL;
+ }
+
+ xm_share = shareContext ? shareContext->xmesa : NULL;
+ context->xmesa = XMesaCreateContext(xm_vis, xm_share);
+ if (!context->xmesa) {
+ xfree(context);
+ return NULL;
+ }
+
+ return &context->base;
}
-Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp, int *rootDepthp,
- VisualID *defaultVisp, unsigned long sizes,
- int bitsPerRGB)
+static void
+__glXMesaScreenDestroy(__GLXscreen *screen)
{
- /*
- * Setup the visuals supported by this particular screen.
- */
- return init_visuals(nvisualp, visualp, defaultVisp,
- *ndepthp, *depthp, *rootDepthp);
+ __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+ int i;
+
+ for (i = 0; i < screen->numVisuals; i++) {
+ if (mesaScreen->xm_vis[i])
+ XMesaDestroyVisual(mesaScreen->xm_vis[i]);
+ }
+
+ xfree(mesaScreen->xm_vis);
+
+ __glXScreenDestroy(screen);
+
+ xfree(screen);
}
-static void fixup_visuals(int screen)
+static XMesaVisual
+find_mesa_visual(__GLXscreen *screen, VisualID vid)
{
- ScreenPtr pScreen = screenInfo.screens[screen];
- __MESA_screen *pMScr = &MESAScreens[screen];
- int j;
- __GLcontextModes *modes;
-
- for ( modes = pMScr->modes ; modes != NULL ; modes = modes->next ) {
- const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
- const int nplanes = (modes->rgbBits - modes->alphaBits);
- const VisualPtr pVis = pScreen->visuals;
+ __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen;
+ const __GLcontextModes *modes;
+ unsigned i = 0;
- /* Find a visual that matches the GLX visual's class and size */
- for (j = 0; j < pScreen->numVisuals; j++) {
- if (pVis[j].class == vis_class &&
- pVis[j].nplanes == nplanes) {
-
- /* Fixup the masks */
- modes->redMask = pVis[j].redMask;
- modes->greenMask = pVis[j].greenMask;
- modes->blueMask = pVis[j].blueMask;
-
- /* Recalc the sizes */
- modes->redBits = count_bits(modes->redMask);
- modes->greenBits = count_bits(modes->greenMask);
- modes->blueBits = count_bits(modes->blueMask);
- }
+ for ( modes = screen->modes ; modes != NULL ; modes = modes->next ) {
+ if ( modes->visualID == vid ) {
+ break;
}
+
+ i++;
}
+
+ return (modes != NULL) ? mesaScreen->xm_vis[i] : NULL;
}
-static void init_screen_visuals(int screen)
+static void init_screen_visuals(__GLXMESAscreen *screen)
{
- ScreenPtr pScreen = screenInfo.screens[screen];
+ ScreenPtr pScreen = screen->base.pScreen;
__GLcontextModes *modes;
XMesaVisual *pXMesaVisual;
int *used;
- int i, j;
+ int i, j, size;
/* Alloc space for the list of XMesa visuals */
- pXMesaVisual = (XMesaVisual *)__glXMalloc(MESAScreens[screen].num_vis *
- sizeof(XMesaVisual));
- __glXMemset(pXMesaVisual, 0,
- MESAScreens[screen].num_vis * sizeof(XMesaVisual));
+ size = screen->base.numVisuals * sizeof(XMesaVisual);
+ pXMesaVisual = (XMesaVisual *) xalloc(size);
+ memset(pXMesaVisual, 0, size);
/* FIXME: Change 'used' to be a array of bits (rather than of ints),
* FIXME: create a stack array of 8 or 16 bytes. If 'numVisuals' is less
@@ -559,13 +339,11 @@ static void init_screen_visuals(int screen)
* FIXME: __glXMalloc / __glXFree. If nothing else, convert 'used' to
* FIXME: array of bytes instead of ints!
*/
- used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
- __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
+ used = (int *) xalloc(pScreen->numVisuals * sizeof(int));
+ memset(used, 0, pScreen->numVisuals * sizeof(int));
i = 0;
- for ( modes = MESAScreens[screen].modes
- ; modes != NULL
- ; modes = modes->next ) {
+ for ( modes = screen->base.modes; modes != NULL; modes = modes->next ) {
const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
const int nplanes = (modes->rgbBits - modes->alphaBits);
const VisualPtr pVis = pScreen->visuals;
@@ -621,30 +399,23 @@ static void init_screen_visuals(int screen)
__glXFree(used);
- MESAScreens[screen].xm_vis = pXMesaVisual;
+ screen->xm_vis = pXMesaVisual;
}
-Bool __MESA_screenProbe(int screen)
+static __GLXscreen *
+__glXMesaScreenProbe(ScreenPtr pScreen)
{
- /*
- * Set up the current screen's visuals.
- */
- __glDDXScreenInfo.modes = MESAScreens[screen].modes;
- __glDDXScreenInfo.pVisualPriv = MESAScreens[screen].private;
- __glDDXScreenInfo.numVisuals =
- __glDDXScreenInfo.numUsableVisuals = MESAScreens[screen].num_vis;
+ __GLXMESAscreen *screen;
- /*
- * Set the current screen's createContext routine. This could be
- * wrapped by a DDX GLX context creation routine.
- */
- __glDDXScreenInfo.createContext = __MESA_createContext;
+ screen = xalloc(sizeof *screen);
+ if (screen == NULL)
+ return NULL;
- /*
- * The ordering of the rgb compenents might have been changed by the
- * driver after mi initialized them.
- */
- fixup_visuals(screen);
+ __glXScreenInit(&screen->base, pScreen);
+
+ screen->base.destroy = __glXMesaScreenDestroy;
+ screen->base.createContext = __glXMesaScreenCreateContext;
+ screen->base.pScreen = pScreen;
/*
* Find the GLX visuals that are supported by this screen and create
@@ -652,263 +423,11 @@ Bool __MESA_screenProbe(int screen)
*/
init_screen_visuals(screen);
- return TRUE;
-}
-
-extern void __MESA_resetExtension(void)
-{
- int i, j;
-
- XMesaReset();
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- for (j = 0; j < MESAScreens[i].num_vis; j++) {
- if (MESAScreens[i].xm_vis[j]) {
- XMesaDestroyVisual(MESAScreens[i].xm_vis[j]);
- MESAScreens[i].xm_vis[j] = NULL;
- }
- }
- _gl_context_modes_destroy( MESAScreens[i].modes );
- MESAScreens[i].modes = NULL;
- __glXFree(MESAScreens[i].private);
- MESAScreens[i].private = NULL;
- __glXFree(MESAScreens[i].xm_vis);
- MESAScreens[i].xm_vis = NULL;
- MESAScreens[i].num_vis = 0;
- }
- __glDDXScreenInfo.modes = NULL;
- MESA_CC = NULL;
-}
-
-void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv)
-{
- DrawablePtr pDraw = glxPriv->pDraw;
- XMesaVisual xm_vis = find_mesa_visual(pDraw->pScreen->myNum,
- glxPriv->modes->visualID);
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
- __MESA_buffer buf;
-
- if (xm_vis == NULL) {
- ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
- glxPriv->modes->visualID);
- }
- buf = (__MESA_buffer)__glXMalloc(sizeof(struct __MESA_bufferRec));
-
- /* Create Mesa's buffers */
- if (glxPriv->type == DRAWABLE_WINDOW) {
- buf->xm_buf = (void *)XMesaCreateWindowBuffer(xm_vis,
- (WindowPtr)pDraw);
- } else {
- buf->xm_buf = (void *)XMesaCreatePixmapBuffer(xm_vis,
- (PixmapPtr)pDraw, 0);
- }
-
- /* Wrap the front buffer's resize routine */
- buf->fbresize = glPriv->frontBuffer.resize;
- glPriv->frontBuffer.resize = __MESA_resizeBuffers;
-
- /* Wrap the swap buffers routine */
- buf->fbswap = glxPriv->swapBuffers;
- glxPriv->swapBuffers = __MESA_swapBuffers;
-
- /* Save Mesa's private buffer structure */
- glPriv->private = (void *)buf;
- glPriv->freePrivate = __MESA_destroyBuffer;
-}
-
-GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buffer,
- GLint x, GLint y,
- GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv,
- GLuint bufferMask)
-{
- __MESA_buffer buf = (__MESA_buffer)glPriv->private;
-
- if (buf->xm_buf)
- XMesaResizeBuffers(buf->xm_buf);
-
- return (*buf->fbresize)(buffer, x, y, width, height, glPriv, bufferMask);
-}
-
-GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv)
-{
- __MESA_buffer buf = (__MESA_buffer)glxPriv->glPriv.private;
-
- /*
- ** Do not call the wrapped swap buffers routine since Mesa has
- ** already done the swap.
- */
- XMesaSwapBuffers(buf->xm_buf);
-
- return GL_TRUE;
-}
-
-void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv)
-{
- __MESA_buffer buf = (__MESA_buffer)glPriv->private;
- __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
-
- /* Destroy Mesa's buffers */
- if (buf->xm_buf)
- XMesaDestroyBuffer(buf->xm_buf);
-
- /* Unwrap these routines */
- glxPriv->swapBuffers = buf->fbswap;
- glPriv->frontBuffer.resize = buf->fbresize;
-
- __glXFree(glPriv->private);
- glPriv->private = NULL;
-}
-
-__GLinterface *__MESA_createContext(__GLimports *imports,
- __GLcontextModes *modes,
- __GLinterface *shareGC)
-{
- __GLcontext *gl_ctx = NULL;
- __GLcontext *m_share = NULL;
- __GLXcontext *glxc = (__GLXcontext *)imports->other;
- XMesaVisual xm_vis;
-
- if (shareGC)
- m_share = (__GLcontext *)shareGC;
-
- xm_vis = find_mesa_visual(glxc->pScreen->myNum, glxc->modes->visualID);
- if (xm_vis) {
- XMesaContext xmshare = m_share ? m_share->DriverCtx : 0;
- XMesaContext xmctx = XMesaCreateContext(xm_vis, xmshare);
- gl_ctx = xmctx ? &xmctx->mesa : 0;
- }
- else {
- ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n",
- glxc->modes->visualID);
- }
-
-
- if (!gl_ctx)
- return NULL;
-
- gl_ctx->imports = *imports;
- gl_ctx->exports.destroyContext = __MESA_destroyContext;
- gl_ctx->exports.loseCurrent = __MESA_loseCurrent;
- gl_ctx->exports.makeCurrent = __MESA_makeCurrent;
- gl_ctx->exports.shareContext = __MESA_shareContext;
- gl_ctx->exports.copyContext = __MESA_copyContext;
- gl_ctx->exports.forceCurrent = __MESA_forceCurrent;
- gl_ctx->exports.notifyResize = __MESA_notifyResize;
- gl_ctx->exports.notifyDestroy = __MESA_notifyDestroy;
- gl_ctx->exports.notifySwapBuffers = __MESA_notifySwapBuffers;
- gl_ctx->exports.dispatchExec = __MESA_dispatchExec;
- gl_ctx->exports.beginDispatchOverride = __MESA_beginDispatchOverride;
- gl_ctx->exports.endDispatchOverride = __MESA_endDispatchOverride;
-
- return (__GLinterface *)gl_ctx;
-}
-
-GLboolean __MESA_destroyContext(__GLcontext *gc)
-{
- XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
- XMesaDestroyContext( xmesa );
- return GL_TRUE;
-}
-
-GLboolean __MESA_loseCurrent(__GLcontext *gc)
-{
- XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
- MESA_CC = NULL;
- __glXLastContext = NULL;
- return XMesaLoseCurrent(xmesa);
-}
-
-GLboolean __MESA_makeCurrent(__GLcontext *gc)
-{
- __GLdrawablePrivate *drawPriv = gc->imports.getDrawablePrivate( gc );
- __MESA_buffer drawBuf = (__MESA_buffer)drawPriv->private;
- __GLdrawablePrivate *readPriv = gc->imports.getReadablePrivate( gc );
- __MESA_buffer readBuf = (__MESA_buffer)readPriv->private;
- XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
-
- MESA_CC = gc;
- return XMesaMakeCurrent2(xmesa, drawBuf->xm_buf, readBuf->xm_buf);
-}
-
-GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare)
-{
- /* NOT_DONE */
- /* XXX I don't see where/how this could ever be called */
- ErrorF("__MESA_shareContext\n");
- return GL_FALSE;
-}
-
-GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask)
-{
- XMesaContext xm_dst = (XMesaContext) dst->DriverCtx;
- const XMesaContext xm_src = (const XMesaContext) src->DriverCtx;
- _mesa_copy_context(&xm_src->mesa, &xm_dst->mesa, mask);
- return GL_TRUE;
-}
-
-GLboolean __MESA_forceCurrent(__GLcontext *gc)
-{
- XMesaContext xmesa = (XMesaContext) gc->DriverCtx;
- MESA_CC = gc;
- return XMesaForceCurrent(xmesa);
-}
-
-GLboolean __MESA_notifyResize(__GLcontext *gc)
-{
- /* NOT_DONE */
- ErrorF("__MESA_notifyResize\n");
- return GL_FALSE;
-}
-
-void __MESA_notifyDestroy(__GLcontext *gc)
-{
- /* NOT_DONE */
- ErrorF("__MESA_notifyDestroy\n");
- return;
-}
-
-void __MESA_notifySwapBuffers(__GLcontext *gc)
-{
- _mesa_notifySwapBuffers(gc);
-}
-
-struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc)
-{
- /* NOT_DONE */
- ErrorF("__MESA_dispatchExec\n");
- return NULL;
-}
-
-void __MESA_beginDispatchOverride(__GLcontext *gc)
-{
- /* NOT_DONE */
- ErrorF("__MESA_beginDispatchOverride\n");
- return;
-}
-
-void __MESA_endDispatchOverride(__GLcontext *gc)
-{
- /* NOT_DONE */
- ErrorF("__MESA_endDispatchOverride\n");
- return;
-}
-
-
-/*
- * Server-side GLX uses these functions which are normally defined
- * in the OpenGL SI.
- */
-
-GLuint __glFloorLog2(GLuint val)
-{
- int c = 0;
-
- while (val > 1) {
- c++;
- val >>= 1;
- }
- return c;
+ return &screen->base;
}
+__GLXprovider __glXMesaProvider = {
+ __glXMesaScreenProbe,
+ "MESA",
+ NULL
+};
diff --git a/GL/mesa/X/xf86glxint.h b/GL/mesa/X/xf86glxint.h
index 974ff0364..4e51215bc 100644
--- a/GL/mesa/X/xf86glxint.h
+++ b/GL/mesa/X/xf86glxint.h
@@ -43,60 +43,4 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <GL/gl.h>
#include <GL/xmesa.h>
-typedef struct __MESA_screenRec __MESA_screen;
-struct __MESA_screenRec {
- int num_vis;
- __GLcontextModes *modes;
- XMesaVisual *xm_vis;
- void **private;
-};
-
-typedef struct __MESA_bufferRec *__MESA_buffer;
-struct __MESA_bufferRec {
- XMesaBuffer xm_buf;
- GLboolean (*fbresize)(__GLdrawableBuffer *buf,
- GLint x, GLint y, GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv, GLuint bufferMask);
- GLboolean (*fbswap)(__GLXdrawablePrivate *glxPriv);
-};
-
-extern void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates);
-extern Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp, int *rootDepthp,
- VisualID *defaultVisp, unsigned long sizes,
- int bitsPerRGB);
-extern Bool __MESA_screenProbe(int screen);
-
-extern void __MESA_resetExtension(void);
-
-extern void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv);
-extern GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buf,
- GLint x, GLint y,
- GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv,
- GLuint bufferMask);
-extern GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv);
-extern void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv);
-
-extern __GLinterface *__MESA_createContext(__GLimports *imports,
- __GLcontextModes *modes,
- __GLinterface *shareGC);
-extern GLboolean __MESA_destroyContext(__GLcontext *gc);
-extern GLboolean __MESA_loseCurrent(__GLcontext *gc);
-extern GLboolean __MESA_makeCurrent(__GLcontext *gc);
-extern GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare);
-extern GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask);
-extern GLboolean __MESA_forceCurrent(__GLcontext *gc);
-
-extern GLboolean __MESA_notifyResize(__GLcontext *gc);
-extern void __MESA_notifyDestroy(__GLcontext *gc);
-extern void __MESA_notifySwapBuffers(__GLcontext *gc);
-extern struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc);
-extern void __MESA_beginDispatchOverride(__GLcontext *gc);
-extern void __MESA_endDispatchOverride(__GLcontext *gc);
-
-extern GLuint __glFloorLog2(GLuint val);
-
#endif /* _XF86GLXINT_H_ */
diff --git a/GL/mesa/swrast/Makefile.am b/GL/mesa/swrast/Makefile.am
index 5a0ed9cd3..973de3ac2 100644
--- a/GL/mesa/swrast/Makefile.am
+++ b/GL/mesa/swrast/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES = -I@MESA_SOURCE@/include \
-I../math \
-I../shader \
-I../shader/slang \
+ -I../shader/slang \
-I../swrast \
-I../swrast_setup \
-I../tnl \
diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index fa14f629d..afd1f5501 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -63,6 +63,7 @@ symlink_mesa_glapi() {
dst_dir mesa/glapi
action dispatch.h
+ action glapi.c
action glapi.h
action glapioffsets.h
action glapitable.h