aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/GL
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/GL')
-rw-r--r--nx-X11/programs/Xserver/GL/apple/Imakefile49
-rw-r--r--nx-X11/programs/Xserver/GL/apple/aglGlx.c1355
-rw-r--r--nx-X11/programs/Xserver/GL/apple/indirect.c1380
-rw-r--r--nx-X11/programs/Xserver/GL/dri/Imakefile35
-rw-r--r--nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference35
-rw-r--r--nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference34
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dri-def.cpp50
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dri.c2109
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dri.h345
-rw-r--r--nx-X11/programs/Xserver/GL/dri/drimodule.c127
-rw-r--r--nx-X11/programs/Xserver/GL/dri/dristruct.h105
-rw-r--r--nx-X11/programs/Xserver/GL/dri/sarea.h94
-rw-r--r--nx-X11/programs/Xserver/GL/dri/xf86dri.c649
-rw-r--r--nx-X11/programs/Xserver/GL/windows/ChangeLog64
-rwxr-xr-xnx-X11/programs/Xserver/GL/windows/Imakefile36
-rw-r--r--nx-X11/programs/Xserver/GL/windows/glwindows.h64
-rwxr-xr-xnx-X11/programs/Xserver/GL/windows/glwrap.c583
-rwxr-xr-xnx-X11/programs/Xserver/GL/windows/indirect.c1605
18 files changed, 0 insertions, 8719 deletions
diff --git a/nx-X11/programs/Xserver/GL/apple/Imakefile b/nx-X11/programs/Xserver/GL/apple/Imakefile
deleted file mode 100644
index 36b780c73..000000000
--- a/nx-X11/programs/Xserver/GL/apple/Imakefile
+++ /dev/null
@@ -1,49 +0,0 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/apple/Imakefile,v 1.2 2003/09/16 00:36:11 torrey Exp $
-
-#include <Server.tmpl>
-
- XPRDIR = $(SERVERSRC)/hw/darwin/quartz/xpr
-
-LinkSourceFile(x-list.c,$(XPRDIR))
-LinkSourceFile(x-list.h,$(XPRDIR))
-LinkSourceFile(x-hash.c,$(XPRDIR))
-LinkSourceFile(x-hash.h,$(XPRDIR))
-LinkSourceFile(compsize.c,$(MESASRCDIR)/src/glx/x11)
-
- BASE_SRCS = compsize.c
- BASE_OBJS = compsize.o
-
- AGL_SRCS = aglGlx.c
- AGL_OBJS = aglGlx.o
-
-#if HasXplugin
- GL_SRCS = indirect.c x-hash.c x-list.c
- GL_OBJS = indirect.o x-hash.o x-list.o
-
- AS = /System/Library/Frameworks/ApplicationServices.framework
-
- GL_INCLUDES = -I$(LIBSRC)/GL/apple -I$(XPRDIR) -I$(XPINCDIR) \
- -F$(AS)/Frameworks
-#endif
-
- SRCS = $(BASE_SRCS) $(AGL_SRCS) $(GL_SRCS)
- OBJS = $(BASE_OBJS) $(AGL_OBJS) $(GL_OBJS)
-
- INCLUDES = -I. -I$(INCLUDESRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) \
- -I$(LIBSRC)/GL/glx -I$(LIBSRC)/GL/include \
- -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(FONTINCSRC) \
- -I$(SERVERSRC)/render -I$(SERVERSRC)/GL/include \
- -I$(SERVERSRC)/GL/glx -I$(SERVERSRC)/hw/darwin/quartz/cr \
- -I$(SERVERSRC)/hw/darwin/quartz $(GL_INCLUDES) \
- -I$(MESASRCDIR)/include -I$(MESASRCDIR)/src/mesa/glapi \
- -I$(XF86OSSRC)
-
- DEFINES = $(GLX_DEFINES)
-
-NormalLibraryTarget(AGLcore,$(AGL_OBJS) $(BASE_OBJS))
-#if HasXplugin
-NormalLibraryTarget(CGLcore,$(GL_OBJS) $(BASE_OBJS))
-#endif
-NormalLibraryObjectRule()
-
-DependTarget()
diff --git a/nx-X11/programs/Xserver/GL/apple/aglGlx.c b/nx-X11/programs/Xserver/GL/apple/aglGlx.c
deleted file mode 100644
index be846be83..000000000
--- a/nx-X11/programs/Xserver/GL/apple/aglGlx.c
+++ /dev/null
@@ -1,1355 +0,0 @@
-/*
- * GLX implementation that uses Apple's AGL.framework for OpenGL
- *
- * FIXME: This file and indirect.c are very similar. The two should be
- * merged by introducing suitable abstractions.
- */
-/*
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
- *
- * Large portions of this file are copied from Mesa's xf86glx.c,
- * which contains the following copyright:
- *
- * 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, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) 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.
- */
-/* $XFree86: xc/programs/Xserver/GL/apple/aglGlx.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include <AGL/agl.h>
-#include "cr.h"
-
-// X11 and X11's glx
-#undef BOOL
-#define BOOL xBOOL
-#include "quartz.h"
-#include <miscstruct.h>
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
-#include <glxutil.h>
-#include <glxscreens.h>
-#include <GL/internal/glcore.h>
-#undef BOOL
-
-#include "glcontextmodes.h"
-
-// ggs: needed to call back to glx with visual configs
-extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
-
-// Write debugging output, or not
-#ifdef GLAQUA_DEBUG
-#define GLAQUA_DEBUG_MSG ErrorF
-#else
-#define GLAQUA_DEBUG_MSG(a, ...)
-#endif
-
-
-// The following GL functions don't have an EXT suffix in OpenGL.framework.
-GLboolean glAreTexturesResidentEXT (GLsizei a, const GLuint *b, GLboolean *c) {
- return glAreTexturesResident(a, b, c);
-}
-void glDeleteTexturesEXT (GLsizei d, const GLuint *e) {
- glDeleteTextures(d, e);
-}
-void glGenTexturesEXT (GLsizei f, GLuint *g) {
- glGenTextures(f, g);
-}
-GLboolean glIsTextureEXT (GLuint h) {
- return glIsTexture(h);
-}
-
-
-// some prototypes
-static Bool glAquaScreenProbe(int screen);
-static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB);
-static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates);
-static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC);
-static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv);
-static void glAquaResetExtension(void);
-
-
-/*
- * 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, modes, numVisuals,
- * and numUsableVisuals fields must be initialized.
- */
-static __GLXscreenInfo __glDDXScreenInfo = {
- glAquaScreenProbe, /* Must be generic and handle all screens */
- glAquaCreateContext, /* Substitute screen's createContext routine */
- glAquaCreateBuffer, /* 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 */
- "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 */
-};
-
-void *__glXglDDXScreenInfo(void) {
- return &__glDDXScreenInfo;
-}
-
-static __GLXextensionInfo __glDDXExtensionInfo = {
- GL_CORE_APPLE,
- glAquaResetExtension,
- glAquaInitVisuals,
- glAquaSetVisualConfigs
-};
-
-void *__glXglDDXExtensionInfo(void) {
- return &__glDDXExtensionInfo;
-}
-
-// prototypes
-
-static GLboolean glAquaDestroyContext(__GLcontext *gc);
-static GLboolean glAquaLoseCurrent(__GLcontext *gc);
-static GLboolean glAquaMakeCurrent(__GLcontext *gc);
-static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare);
-static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask);
-static GLboolean glAquaForceCurrent(__GLcontext *gc);
-
-/* Drawing surface notification callbacks */
-static GLboolean glAquaNotifyResize(__GLcontext *gc);
-static void glAquaNotifyDestroy(__GLcontext *gc);
-static void glAquaNotifySwapBuffers(__GLcontext *gc);
-
-/* Dispatch table override control for external agents like libGLS */
-static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc);
-static void glAquaBeginDispatchOverride(__GLcontext *gc);
-static void glAquaEndDispatchOverride(__GLcontext *gc);
-
-
-static __GLexports glAquaExports = {
- glAquaDestroyContext,
- glAquaLoseCurrent,
- glAquaMakeCurrent,
- glAquaShareContext,
- glAquaCopyContext,
- glAquaForceCurrent,
-
- glAquaNotifyResize,
- glAquaNotifyDestroy,
- glAquaNotifySwapBuffers,
-
- glAquaDispatchExec,
- glAquaBeginDispatchOverride,
- glAquaEndDispatchOverride
-};
-
-
-typedef struct {
- int num_vis;
- __GLcontextModes *modes;
- void **priv;
-
- // wrapped screen functions
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
-} glAquaScreenRec;
-
-static glAquaScreenRec glAquaScreens[MAXSCREENS];
-
-
-// __GLdrawablePrivate->private
-typedef struct {
- GLboolean (*resize)(__GLdrawableBuffer *buf, GLint x, GLint y,
- GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv,
- GLuint bufferMask);
-} GLAquaDrawableRec;
-
-struct __GLcontextRec {
- struct __GLinterfaceRec interface; // required to be first
-
- AGLContext ctx;
- AGLPixelFormat pixelFormat;
-
- Bool isAttached; // TRUE if ctx is really attached to a window
-};
-
-
-// Context manipulation; return GL_FALSE on failure
-static GLboolean glAquaDestroyContext(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("glAquaDestroyContext (ctx 0x%x)\n", gc->ctx);
-
- if (gc) {
- if (gc->ctx) aglDestroyContext(gc->ctx);
- if (gc->pixelFormat) aglDestroyPixelFormat(gc->pixelFormat);
- free(gc);
- }
-
- return GL_TRUE;
-}
-
-
-static GLboolean glAquaLoseCurrent(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", gc->ctx);
-
- aglSetCurrentContext(NULL);
- __glXLastContext = NULL; // Mesa does this; why?
- gc->isAttached = FALSE;
-
- return GL_TRUE;
-}
-
-
-/*
- * Attach a GL context to a GL drawable
- * If glPriv is NULL, the context is detached.
- */
-static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
-{
- __GLXdrawablePrivate *glxPriv;
-
- if (glPriv == NULL) {
- // attaching to nothing
- GLAQUA_DEBUG_MSG("unattaching\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- return;
- }
-
- // Note that when resizing, the X11 WindowPtr already has its
- // new size and position, but the Aqua window does not.
-
- glxPriv = (__GLXdrawablePrivate *)glPriv->other;
-
- if (glxPriv->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr) glxPriv->pDraw;
- WindowPtr topWin = quartzProcs->TopLevelParent(pWin);
- CRWindowPtr crWinPtr;
- AGLDrawable newPort;
-
- if (glPriv->width <= 0 || glPriv->height <= 0) {
- // attach to zero size drawable - will really attach later
- GLAQUA_DEBUG_MSG("couldn't attach to zero size drawable\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- return;
- }
-
- crWinPtr = (CRWindowPtr) quartzProcs->FrameForWindow(pWin, FALSE);
-
- if (crWinPtr) {
- newPort = (AGLDrawable) crWinPtr->port;
- } else {
- newPort = NULL;
- }
-
- if (newPort) {
- // FIXME: won't be a CGrafPtr if currently offscreen or fullscreen
- AGLDrawable oldPort = aglGetDrawable(gc->ctx);
- // AGLDrawable newPort = GetWindowPort(window);
-
- // Frame is GLdrawable in X11 global coordinates
- // FIXME: Does this work for multiple screens?
- GLint frame[4] = {glPriv->xOrigin, glPriv->yOrigin, glPriv->width, glPriv->height};
- GLAQUA_DEBUG_MSG("global size %d %d %d %d\n",
- frame[0], frame[1], frame[2], frame[3]);
-
- // Convert to window-local coordinates
- frame[0] -= topWin->drawable.x - topWin->borderWidth;
- frame[1] -= topWin->drawable.y - topWin->borderWidth;
-
- // AGL uses flipped coordinates
- frame[1] = topWin->drawable.height + 2*topWin->borderWidth -
- frame[1] - frame[3];
-
- GLAQUA_DEBUG_MSG("local size %d %d %d %d\n",
- frame[0], frame[1], frame[2], frame[3]);
-
- if (oldPort != newPort) {
- // FIXME: retain/release windows
- if (!aglSetDrawable(gc->ctx, newPort)) return;
- }
- if (!aglSetInteger(gc->ctx, AGL_BUFFER_RECT, frame)) return;
- if (!aglEnable(gc->ctx, AGL_BUFFER_RECT)) return;
- if (!aglSetInteger(gc->ctx, AGL_SWAP_RECT, frame)) return;
- if (!aglEnable(gc->ctx, AGL_SWAP_RECT)) return;
- if (!aglUpdateContext(gc->ctx)) return;
-
- gc->isAttached = TRUE;
- GLAQUA_DEBUG_MSG("attached context 0x%x to window 0x%x\n", gc->ctx,
- pWin->drawable.id);
- } else {
- // attach to not-yet-realized window - will really attach later
- GLAQUA_DEBUG_MSG("couldn't attach to unrealized window\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- }
- } else {
- GLAQUA_DEBUG_MSG("attach: attach to non-window unimplemented\n");
- aglSetDrawable(gc->ctx, NULL);
- gc->isAttached = FALSE;
- }
-}
-
-static GLboolean glAquaMakeCurrent(__GLcontext *gc)
-{
- __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
-
- GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", gc->ctx);
-
- if (!gc->isAttached) {
- attach(gc, glPriv);
- }
-
- return aglSetCurrentContext(gc->ctx);
-}
-
-static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare)
-{
- GLAQUA_DEBUG_MSG("glAquaShareContext unimplemented\n");
-
- return GL_TRUE;
-}
-
-
-static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask)
-{
- GLAQUA_DEBUG_MSG("glAquaCopyContext\n");
-
- return aglCopyContext(src->ctx, dst->ctx, mask);
-}
-
-static GLboolean glAquaForceCurrent(__GLcontext *gc)
-{
- // GLAQUA_DEBUG_MSG("glAquaForceCurrent (ctx 0x%x)\n", gc->ctx);
- return aglSetCurrentContext(gc->ctx);
-}
-
-/* Drawing surface notification callbacks */
-
-static GLboolean glAquaNotifyResize(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyResize");
- return GL_TRUE;
-}
-
-static void glAquaNotifyDestroy(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyDestroy");
-}
-
-static void glAquaNotifySwapBuffers(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifySwapBuffers");
-}
-
-/* Dispatch table override control for external agents like libGLS */
-static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaDispatchExec");
- return NULL;
-}
-
-static void glAquaBeginDispatchOverride(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaBeginDispatchOverride");
-}
-
-static void glAquaEndDispatchOverride(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaEndDispatchOverride");
-}
-
-
-static AGLPixelFormat makeFormat(__GLcontextModes *mode)
-{
- int i;
- GLint attr[64]; // currently uses max of 30
- AGLPixelFormat result;
-
- GLAQUA_DEBUG_MSG("makeFormat\n");
-
- i = 0;
-
- // attr [i++] = AGL_ACCELERATED; // require hwaccel - BAD for multiscreen
- // attr [i++] = AGL_NO_RECOVERY; // disable fallback renderers - BAD
-
- if (mode->stereoMode) {
- attr[i++] = AGL_STEREO;
- }
- if (mode->doubleBufferMode) {
- attr[i++] = AGL_DOUBLEBUFFER;
- }
-
- if (mode->colorIndexMode) {
- attr[i++] = AGL_BUFFER_SIZE;
- attr[i++] = mode->indexBits;
- }
-
- if (mode->rgbMode) {
- attr[i++] = AGL_RGBA;
- attr[i++] = AGL_RED_SIZE;
- attr[i++] = mode->redBits;
- attr[i++] = AGL_GREEN_SIZE;
- attr[i++] = mode->greenBits;
- attr[i++] = AGL_BLUE_SIZE;
- attr[i++] = mode->blueBits;
- attr[i++] = AGL_ALPHA_SIZE;
- attr[i++] = mode->alphaBits;
- }
-
- if (mode->haveAccumBuffer) {
- attr[i++] = AGL_ACCUM_RED_SIZE;
- attr[i++] = mode->accumRedBits;
- attr[i++] = AGL_ACCUM_GREEN_SIZE;
- attr[i++] = mode->accumGreenBits;
- attr[i++] = AGL_ACCUM_BLUE_SIZE;
- attr[i++] = mode->accumBlueBits;
- attr[i++] = AGL_ACCUM_ALPHA_SIZE;
- attr[i++] = mode->accumAlphaBits;
- }
- if (mode->haveDepthBuffer) {
- attr[i++] = AGL_DEPTH_SIZE;
- attr[i++] = mode->depthBits;
- }
- if (mode->haveStencilBuffer) {
- attr[i++] = AGL_STENCIL_SIZE;
- attr[i++] = mode->stencilBits;
- }
-
- attr[i++] = AGL_AUX_BUFFERS;
- attr[i++] = mode->numAuxBuffers;
-
- attr[i++] = AGL_LEVEL;
- attr[i++] = mode->level;
-
- // mode->pixmapMode ?
-
- attr[i++] = AGL_NONE; // end of option list
-
- GLAQUA_DEBUG_MSG("makeFormat almost done\n");
- result = aglChoosePixelFormat(NULL, 0, attr);
- GLAQUA_DEBUG_MSG("makeFormat done (0x%x)\n", result);
- return result;
-}
-
-static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC)
-{
- __GLcontext *result;
- __GLcontext *sharectx = (__GLcontext *)shareGC;
-
- GLAQUA_DEBUG_MSG("glAquaCreateContext\n");
-
- result = (__GLcontext *)calloc(1, sizeof(__GLcontext));
- if (!result) return NULL;
-
- result->interface.imports = *imports;
- result->interface.exports = glAquaExports;
-
- result->pixelFormat = makeFormat(mode);
- if (!result->pixelFormat) {
- free(result);
- return NULL;
- }
-
- result->ctx = aglCreateContext(result->pixelFormat,
- (sharectx && sharectx->ctx) ? sharectx->ctx : NULL);
-
- if (!result->ctx) {
- aglDestroyPixelFormat(result->pixelFormat);
- free(result);
- return NULL;
- }
-
- result->isAttached = FALSE;
-
- GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
- return (__GLinterface *)result;
-}
-
-
-Bool
-glAquaRealizeWindow(WindowPtr pWin)
-{
- // If this window has GL contexts, tell them to reattach
- Bool result;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
- __GLXdrawablePrivate *glxPriv;
-
- GLAQUA_DEBUG_MSG("glAquaRealizeWindow\n");
-
- // Allow the window to be created (RootlessRealizeWindow is inside our wrap)
- pScreen->RealizeWindow = screenPriv->RealizeWindow;
- result = pScreen->RealizeWindow(pWin);
- pScreen->RealizeWindow = glAquaRealizeWindow;
-
- // The Aqua window will already have been created (windows are
- // realized from top down)
-
- // Re-attach this window's GL contexts, if any.
- glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
- if (glxPriv) {
- __GLXcontext *gx;
- __GLcontext *gc;
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
- GLAQUA_DEBUG_MSG("glAquaRealizeWindow is GL drawable!\n");
-
- // GL contexts bound to this window for drawing
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
-
- // GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
- }
-
- return result;
-}
-
-Bool
-glAquaUnrealizeWindow(WindowPtr pWin)
-{
- // If this window has GL contexts, tell them to unattach
- Bool result;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
- __GLXdrawablePrivate *glxPriv;
-
- GLAQUA_DEBUG_MSG("glAquaUnrealizeWindow\n");
-
- // The Aqua window may have already been destroyed (windows
- // are unrealized from top down)
-
- // Unattach this window's GL contexts, if any.
- glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
- if (glxPriv) {
- __GLXcontext *gx;
- __GLcontext *gc;
- GLAQUA_DEBUG_MSG("glAquaUnealizeWindow is GL drawable!\n");
-
- // GL contexts bound to this window for drawing
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, NULL);
- }
-
- // GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, NULL);
- }
- }
-
- pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow;
- result = pScreen->UnrealizeWindow(pWin);
- pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
-
- return result;
-}
-
-
-// Originally copied from Mesa
-
-static int numConfigs = 0;
-static __GLXvisualConfig *visualConfigs = NULL;
-static void **visualPrivates = NULL;
-
-/*
- * 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 __GLXvisualConfig NullConfig = {
- -1, /* vid */
- -1, /* class */
- False, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- False, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
-};
-
-
-static int count_bits(unsigned int n)
-{
- int bits = 0;
-
- while (n > 0) {
- if (n & 1) bits++;
- n >>= 1;
- }
- return bits;
-}
-
-
-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;
-
- GLAQUA_DEBUG_MSG("init_visuals\n");
-
- 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++) {
- int count;
-
- count = ((pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor)
- ? numRGBconfigs : numCIconfigs);
- if (count == 0)
- count = 1; /* preserve the existing visual */
-
- numNewVisuals += count;
- }
-
- /* 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;
- glAquaScreens[screenInfo.numScreens-1].modes = modes;
- for (i = j = 0; i < numVisuals; i++) {
- int is_rgb = (pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor);
-
- if (!is_rgb)
- {
- /* We don't support non-rgb visuals for GL. But we don't
- want to remove them either, so just pass them through
- with null glX configs */
-
- 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, & NullConfig );
- modes->visualID = pVisualNew[j].vid;
-
- j++;
-
- continue;
- }
-
- 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 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 */
- glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- glAquaScreens[screenInfo.numScreens-1].priv = 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)
- xfree(visualPrivates);
- visualPrivates = NULL;
-
- return TRUE;
-}
-
-/* based on code in i830_dri.c
- This ends calling glAquaSetVisualConfigs to set the static
- numconfigs, etc. */
-static void
-glAquaInitVisualConfigs(void)
-{
- int lclNumConfigs = 0;
- __GLXvisualConfig *lclVisualConfigs = NULL;
- void **lclVisualPrivates = NULL;
-
- int depth, aux, buffers, stencil, accum;
- int i = 0;
-
- GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
-
- /* count num configs:
- 2 Z buffer (0, 24 bit)
- 2 AUX buffer (0, 2)
- 2 buffers (single, double)
- 2 stencil (0, 8 bit)
- 2 accum (0, 64 bit)
- = 32 configs */
-
- lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
-
- /* alloc */
- lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
- lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
-
- /* fill in configs */
- if (NULL != lclVisualConfigs) {
- i = 0; /* current buffer */
- for (depth = 0; depth < 2; depth++) {
- for (aux = 0; aux < 2; aux++) {
- for (buffers = 0; buffers < 2; buffers++) {
- for (stencil = 0; stencil < 2; stencil++) {
- for (accum = 0; accum < 2; accum++) {
- lclVisualConfigs[i].vid = -1;
- lclVisualConfigs[i].class = -1;
- lclVisualConfigs[i].rgba = TRUE;
- lclVisualConfigs[i].redSize = -1;
- lclVisualConfigs[i].greenSize = -1;
- lclVisualConfigs[i].blueSize = -1;
- lclVisualConfigs[i].redMask = -1;
- lclVisualConfigs[i].greenMask = -1;
- lclVisualConfigs[i].blueMask = -1;
- lclVisualConfigs[i].alphaMask = 0;
- if (accum) {
- lclVisualConfigs[i].accumRedSize = 16;
- lclVisualConfigs[i].accumGreenSize = 16;
- lclVisualConfigs[i].accumBlueSize = 16;
- lclVisualConfigs[i].accumAlphaSize = 16;
- }
- else {
- lclVisualConfigs[i].accumRedSize = 0;
- lclVisualConfigs[i].accumGreenSize = 0;
- lclVisualConfigs[i].accumBlueSize = 0;
- lclVisualConfigs[i].accumAlphaSize = 0;
- }
- lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
- lclVisualConfigs[i].stereo = FALSE;
- lclVisualConfigs[i].bufferSize = -1;
-
- lclVisualConfigs[i].depthSize = depth? 24 : 0;
- lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
- lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
- lclVisualConfigs[i].level = 0;
- lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
- lclVisualConfigs[i].transparentPixel = 0;
- lclVisualConfigs[i].transparentRed = 0;
- lclVisualConfigs[i].transparentGreen = 0;
- lclVisualConfigs[i].transparentBlue = 0;
- lclVisualConfigs[i].transparentAlpha = 0;
- lclVisualConfigs[i].transparentIndex = 0;
- i++;
- }
- }
- }
- }
- }
- }
- if (i != lclNumConfigs)
- GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
-
- GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
-}
-
-
-static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates)
-{
- GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
-
- numConfigs = nconfigs;
- visualConfigs = configs;
- visualPrivates = privates;
-}
-
-static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB)
-{
- GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
-
- if (numConfigs == 0) /* if no configs */
- glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
-
- /*
- * Setup the visuals supported by this particular screen.
- */
- return init_visuals(nvisualp, visualp, defaultVisp,
- *ndepthp, *depthp, *rootDepthp);
-}
-
-
-static void fixup_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- glAquaScreenRec *pScr = &glAquaScreens[screen];
- int j;
- __GLcontextModes *modes;
-
- GLAQUA_DEBUG_MSG("fixup_visuals\n");
-
- for ( modes = pScr->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);
- }
- }
- }
-}
-
-static void init_screen_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- __GLcontextModes *modes;
- int *used;
- int i, j;
-
- GLAQUA_DEBUG_MSG("init_screen_visuals\n");
-
- /* 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
- * FIXME: than 64 or 128 the stack array can be used instead of calling
- * 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));
-
- i = 0;
- for ( modes = glAquaScreens[screen].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;
-
- for (j = 0; j < pScreen->numVisuals; j++) {
- if (pVis[j].class == vis_class &&
- pVis[j].nplanes == nplanes &&
- pVis[j].redMask == modes->redMask &&
- pVis[j].greenMask == modes->greenMask &&
- pVis[j].blueMask == modes->blueMask &&
- !used[j]) {
-
- /* Set the VisualID */
- modes->visualID = pVis[j].vid;
-
- /* Mark this visual used */
- used[j] = 1;
- break;
- }
- }
- if ( j == pScreen->numVisuals ) {
- ErrorF("No matching visual for __GLcontextMode with "
- "visual class = %d (%d), nplanes = %u\n",
- vis_class,
- (int)modes->visualType,
- (unsigned int)(modes->rgbBits - modes->alphaBits) );
- }
- else if ( modes->visualID == -1 ) {
- FatalError( "Matching visual found, but visualID still -1!\n" );
- }
-
- i++;
- }
-
- __glXFree(used);
-}
-
-static Bool glAquaScreenProbe(int screen)
-{
- ScreenPtr pScreen;
- glAquaScreenRec *screenPriv;
-
- GLAQUA_DEBUG_MSG("glAquaScreenProbe\n");
-
- /*
- * Set up the current screen's visuals.
- */
- __glDDXScreenInfo.modes = glAquaScreens[screen].modes;
- __glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv;
- __glDDXScreenInfo.numVisuals =
- __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
-
- /*
- * Set the current screen's createContext routine. This could be
- * wrapped by a DDX GLX context creation routine.
- */
- __glDDXScreenInfo.createContext = glAquaCreateContext;
-
- /*
- * The ordering of the rgb compenents might have been changed by the
- * driver after mi initialized them.
- */
- fixup_visuals(screen);
-
- /*
- * Find the GLX visuals that are supported by this screen and create
- * XMesa's visuals.
- */
- init_screen_visuals(screen);
-
- /*
- * Wrap RealizeWindow and UnrealizeWindow on this screen
- */
- pScreen = screenInfo.screens[screen];
- screenPriv = &glAquaScreens[screen];
- screenPriv->RealizeWindow = pScreen->RealizeWindow;
- pScreen->RealizeWindow = glAquaRealizeWindow;
- screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
- pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
-
- return TRUE;
-}
-
-
-static GLboolean glAquaResizeBuffers(__GLdrawableBuffer *buffer,
- GLint x, GLint y,
- GLuint width, GLuint height,
- __GLdrawablePrivate *glPriv,
- GLuint bufferMask)
-{
- GLAquaDrawableRec *aquaPriv = (GLAquaDrawableRec *)glPriv->private;
- __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
- __GLXcontext *gx;
- __GLcontext *gc;
-
- GLAQUA_DEBUG_MSG("glAquaResizeBuffers to (%d %d %d %d)\n", x, y, width, height);
-
- // update all contexts that point at this drawable for drawing (hack?)
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->nextDrawPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
-
- // update all contexts that point at this drawable for reading (hack?)
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->nextReadPriv) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
-
- return aquaPriv->resize(buffer, x, y, width, height, glPriv, bufferMask);
-}
-
-
-static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv)
-{
- // fixme AGL software renderer will use properties of current QD port (bad)
-
- // swap buffers on only *one* of the contexts
- // (e.g. the last one for drawing)
- __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc;
- if (gc && gc->ctx) aglSwapBuffers(gc->ctx);
-
- return GL_TRUE;
-}
-
-static void glAquaDestroyDrawablePrivate(__GLdrawablePrivate *glPriv)
-{
- GLAQUA_DEBUG_MSG("glAquaDestroyDrawablePrivate\n");
-
- free(glPriv->private);
- glPriv->private = NULL;
-}
-
-static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv)
-{
- GLAquaDrawableRec *aquaPriv = malloc(sizeof(GLAquaDrawableRec));
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
-
- GLAQUA_DEBUG_MSG("glAquaCreateBuffer\n");
-
- // replace swapBuffers (original is never called)
- glxPriv->swapBuffers = glAquaSwapBuffers;
-
- // wrap front buffer resize
- aquaPriv->resize = glPriv->frontBuffer.resize;
- glPriv->frontBuffer.resize = glAquaResizeBuffers;
-
- // stash private data
- glPriv->private = aquaPriv;
- glPriv->freePrivate = glAquaDestroyDrawablePrivate;
-}
-
-
-static void glAquaResetExtension(void)
-{
- GLAQUA_DEBUG_MSG("glAquaResetExtension\n");
- aglResetLibrary();
-}
-
-
-
-// Extra goodies for glx
-
-GLuint __glFloorLog2(GLuint val)
-{
- int c = 0;
-
- while (val > 1) {
- c++;
- val >>= 1;
- }
- return c;
-}
diff --git a/nx-X11/programs/Xserver/GL/apple/indirect.c b/nx-X11/programs/Xserver/GL/apple/indirect.c
deleted file mode 100644
index 448b1f76a..000000000
--- a/nx-X11/programs/Xserver/GL/apple/indirect.c
+++ /dev/null
@@ -1,1380 +0,0 @@
-/*
- * GLX implementation that uses Apple's OpenGL.framework
- * (Indirect rendering path)
- */
-/*
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- * Copyright (c) 2002 Apple Computer, Inc.
- * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
- *
- * Portions of this file are copied from Mesa's xf86glx.c,
- * which contains the following copyright:
- *
- * 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, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) 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.
- */
-/* $XFree86: xc/programs/Xserver/GL/apple/indirect.c,v 1.2 2003/09/16 00:36:11 torrey Exp $ */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "dri.h"
-#include "quartz.h"
-
-#include <CoreGraphics/CoreGraphics.h>
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/CGLContext.h>
-
-// X11 and X11's glx
-#include <miscstruct.h>
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
-#include <glxutil.h>
-#include <glxscreens.h>
-#include <GL/internal/glcore.h>
-#include "x-hash.h"
-#include "x-list.h"
-
-#include "glcontextmodes.h"
-
-// ggs: needed to call back to glx with visual configs
-extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
-
-
-// Write debugging output, or not
-#ifdef GLAQUA_DEBUG
-#define GLAQUA_DEBUG_MSG ErrorF
-#else
-#define GLAQUA_DEBUG_MSG(a, ...)
-#endif
-
-
-// The following GL functions don't have an EXT suffix in OpenGL.framework.
-GLboolean glAreTexturesResidentEXT(GLsizei a, const GLuint *b, GLboolean *c) {
- return glAreTexturesResident(a, b, c);
-}
-void glDeleteTexturesEXT(GLsizei d, const GLuint *e) {
- glDeleteTextures(d, e);
-}
-void glGenTexturesEXT(GLsizei f, GLuint *g) {
- glGenTextures(f, g);
-}
-GLboolean glIsTextureEXT(GLuint h) {
- return glIsTexture(h);
-}
-
-// some prototypes
-static Bool glAquaScreenProbe(int screen);
-static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB);
-static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates);
-static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC);
-static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv);
-static void glAquaResetExtension(void);
-
-/*
- * 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, modes, numVisuals,
- * and numUsableVisuals fields must be initialized.
- */
-static __GLXscreenInfo __glDDXScreenInfo = {
- glAquaScreenProbe, /* Must be generic and handle all screens */
- glAquaCreateContext, /* Substitute screen's createContext routine */
- glAquaCreateBuffer, /* 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 */
- "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 */
-};
-
-void *__glXglDDXScreenInfo(void) {
- return &__glDDXScreenInfo;
-}
-
-static __GLXextensionInfo __glDDXExtensionInfo = {
- GL_CORE_APPLE,
- glAquaResetExtension,
- glAquaInitVisuals,
- glAquaSetVisualConfigs
-};
-
-void *__glXglDDXExtensionInfo(void) {
- return &__glDDXExtensionInfo;
-}
-
-// prototypes
-
-static GLboolean glAquaDestroyContext(__GLcontext *gc);
-static GLboolean glAquaLoseCurrent(__GLcontext *gc);
-static GLboolean glAquaMakeCurrent(__GLcontext *gc);
-static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare);
-static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask);
-static GLboolean glAquaForceCurrent(__GLcontext *gc);
-
-/* Drawing surface notification callbacks */
-static GLboolean glAquaNotifyResize(__GLcontext *gc);
-static void glAquaNotifyDestroy(__GLcontext *gc);
-static void glAquaNotifySwapBuffers(__GLcontext *gc);
-
-/* Dispatch table override control for external agents like libGLS */
-static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc);
-static void glAquaBeginDispatchOverride(__GLcontext *gc);
-static void glAquaEndDispatchOverride(__GLcontext *gc);
-
-static __GLexports glAquaExports = {
- glAquaDestroyContext,
- glAquaLoseCurrent,
- glAquaMakeCurrent,
- glAquaShareContext,
- glAquaCopyContext,
- glAquaForceCurrent,
-
- glAquaNotifyResize,
- glAquaNotifyDestroy,
- glAquaNotifySwapBuffers,
-
- glAquaDispatchExec,
- glAquaBeginDispatchOverride,
- glAquaEndDispatchOverride
-};
-
-typedef struct {
- int num_vis;
- __GLcontextModes *modes;
- void **priv;
-
- // wrapped screen functions
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
-} glAquaScreenRec;
-
-static glAquaScreenRec glAquaScreens[MAXSCREENS];
-
-// __GLdrawablePrivate->private
-typedef struct {
- DrawablePtr pDraw;
- xp_surface_id sid;
-} GLAquaDrawableRec;
-
-struct __GLcontextRec {
- struct __GLinterfaceRec interface; // required to be first
-
- CGLContextObj ctx;
- CGLPixelFormatObj pixelFormat;
-
- /* set when attached */
- xp_surface_id sid;
-
- unsigned isAttached :1;
-};
-
-/* maps from surface id -> list of __GLcontext */
-static x_hash_table *surface_hash;
-
-
-// Context manipulation; return GL_FALSE on failure
-static GLboolean glAquaDestroyContext(__GLcontext *gc)
-{
- x_list *lst;
-
- GLAQUA_DEBUG_MSG("glAquaDestroyContext (ctx 0x%x)\n",
- (unsigned int) gc->ctx);
-
- if (gc != NULL)
- {
- if (gc->sid != 0 && surface_hash != NULL)
- {
- lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
- lst = x_list_remove(lst, gc);
- x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
- }
-
- if (gc->ctx != NULL)
- CGLDestroyContext(gc->ctx);
-
- if (gc->pixelFormat != NULL)
- CGLDestroyPixelFormat(gc->pixelFormat);
-
- free(gc);
- }
-
- return GL_TRUE;
-}
-
-static GLboolean glAquaLoseCurrent(__GLcontext *gc)
-{
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%x)\n", (unsigned int) gc->ctx);
-
- gl_err = CGLSetCurrentContext(NULL);
- if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
- __glXLastContext = NULL; // Mesa does this; why?
-
- return GL_TRUE;
-}
-
-/* Called when a surface is destroyed as a side effect of destroying
- the window it's attached to. */
-static void surface_notify(void *_arg, void *data)
-{
- DRISurfaceNotifyArg *arg = _arg;
- GLAquaDrawableRec *aquaPriv = data;
- __GLcontext *gc;
- x_list *lst;
-
- switch (arg->kind)
- {
- case AppleDRISurfaceNotifyDestroyed:
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, (void *) arg->id);
-
- aquaPriv->pDraw = NULL;
- aquaPriv->sid = 0;
- break;
-
- case AppleDRISurfaceNotifyChanged:
- if (surface_hash != NULL)
- {
- lst = x_hash_table_lookup(surface_hash, (void *) arg->id, NULL);
- for (; lst != NULL; lst = lst->next)
- {
- gc = lst->data;
- xp_update_gl_context(gc->ctx);
- }
- }
- break;
- }
-}
-
-static void unattach(__GLcontext *gc)
-{
- x_list *lst;
-
- if (gc->isAttached)
- {
- GLAQUA_DEBUG_MSG("unattaching\n");
-
- if (surface_hash != NULL)
- {
- lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
- lst = x_list_remove(lst, gc);
- x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
- }
-
- CGLClearDrawable(gc->ctx);
- gc->isAttached = FALSE;
- gc->sid = 0;
- }
-}
-
-static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
-{
- __GLXdrawablePrivate *glxPriv;
- GLAquaDrawableRec *aquaPriv;
- DrawablePtr pDraw;
-
- glxPriv = (__GLXdrawablePrivate *)glPriv->other;
- aquaPriv = (GLAquaDrawableRec *)glPriv->private;
- pDraw = glxPriv->pDraw;
-
- if (aquaPriv->sid == 0)
- {
- if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
- 0, &aquaPriv->sid, NULL,
- surface_notify, aquaPriv))
- {
- return;
- }
- aquaPriv->pDraw = pDraw;
- }
-
- if (!gc->isAttached || gc->sid != aquaPriv->sid)
- {
- x_list *lst;
-
- if (xp_attach_gl_context(gc->ctx, aquaPriv->sid) != Success)
- {
- quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw,
- surface_notify, aquaPriv);
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, (void *) aquaPriv->sid);
-
- aquaPriv->sid = 0;
- return;
- }
-
- gc->isAttached = TRUE;
- gc->sid = aquaPriv->sid;
-
- if (surface_hash == NULL)
- surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
-
- lst = x_hash_table_lookup(surface_hash, (void *) gc->sid, NULL);
- if (x_list_find(lst, gc) == NULL)
- {
- lst = x_list_prepend(lst, gc);
- x_hash_table_insert(surface_hash, (void *) gc->sid, lst);
- }
-
- GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
- (unsigned int) aquaPriv->sid);
- }
-}
-
-static GLboolean glAquaMakeCurrent(__GLcontext *gc)
-{
- __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%x)\n", (unsigned int) gc->ctx);
-
- attach(gc, glPriv);
-
- gl_err = CGLSetCurrentContext(gc->ctx);
- if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
- return gl_err == 0;
-}
-
-static GLboolean glAquaShareContext(__GLcontext *gc, __GLcontext *gcShare)
-{
- GLAQUA_DEBUG_MSG("glAquaShareContext unimplemented\n");
-
- return GL_TRUE;
-}
-
-static GLboolean glAquaCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask)
-{
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaCopyContext\n");
-
- gl_err = CGLCopyContext(src->ctx, dst->ctx, mask);
- if (gl_err != 0)
- ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
-
- return gl_err == 0;
-}
-
-static GLboolean glAquaForceCurrent(__GLcontext *gc)
-{
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaForceCurrent (ctx 0x%x)\n",
- (unsigned int) gc->ctx);
-
- gl_err = CGLSetCurrentContext(gc->ctx);
- if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
- return gl_err == 0;
-}
-
-/* Drawing surface notification callbacks */
-
-static GLboolean glAquaNotifyResize(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyResize");
- return GL_TRUE;
-}
-
-static void glAquaNotifyDestroy(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifyDestroy");
-}
-
-static void glAquaNotifySwapBuffers(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaNotifySwapBuffers");
-}
-
-/* Dispatch table override control for external agents like libGLS */
-static struct __GLdispatchStateRec* glAquaDispatchExec(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaDispatchExec");
- return NULL;
-}
-
-static void glAquaBeginDispatchOverride(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaBeginDispatchOverride");
-}
-
-static void glAquaEndDispatchOverride(__GLcontext *gc)
-{
- GLAQUA_DEBUG_MSG("unimplemented glAquaEndDispatchOverride");
-}
-
-static CGLPixelFormatObj makeFormat(__GLcontextModes *mode)
-{
- int i;
- CGLPixelFormatAttribute attr[64]; // currently uses max of 30
- CGLPixelFormatObj result;
- long n_formats;
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("makeFormat\n");
-
- if (!mode->rgbMode)
- return NULL;
-
- i = 0;
-
- // attr [i++] = kCGLPFAAcelerated; // require hwaccel - BAD for multiscreen
- // attr [i++] = kCGLPFANoRecovery; // disable fallback renderers - BAD
-
- if (mode->stereoMode) {
- attr[i++] = kCGLPFAStereo;
- }
- if (mode->doubleBufferMode) {
- attr[i++] = kCGLPFADoubleBuffer;
- }
-
- if (mode->colorIndexMode) {
- /* ignored */
- }
-
- if (mode->rgbMode) {
- attr[i++] = kCGLPFAColorSize;
- attr[i++] = mode->redBits + mode->greenBits + mode->blueBits;
- attr[i++] = kCGLPFAAlphaSize;
- attr[i++] = 1; /* FIXME: ignoring mode->alphaBits which is always 0 */
- }
-
- if (mode->haveAccumBuffer) {
- attr[i++] = kCGLPFAAccumSize;
- attr[i++] = mode->accumRedBits + mode->accumGreenBits
- + mode->accumBlueBits + mode->accumAlphaBits;
- }
- if (mode->haveDepthBuffer) {
- attr[i++] = kCGLPFADepthSize;
- attr[i++] = mode->depthBits;
- }
- if (mode->haveStencilBuffer) {
- attr[i++] = kCGLPFAStencilSize;
- attr[i++] = mode->stencilBits;
- }
-
- attr[i++] = kCGLPFAAuxBuffers;
- attr[i++] = mode->numAuxBuffers;
-
- /* mode->level ignored */
-
- /* mode->pixmapMode ? */
-
- attr[i++] = 0;
-
- GLAQUA_DEBUG_MSG("makeFormat almost done\n");
-
- result = NULL;
- gl_err = CGLChoosePixelFormat(attr, &result, &n_formats);
- if (gl_err != 0)
- ErrorF("CGLChoosePixelFormat error: %s\n", CGLErrorString(gl_err));
-
- GLAQUA_DEBUG_MSG("makeFormat done (0x%x)\n", (unsigned int) result);
-
- return result;
-}
-
-static __GLinterface *glAquaCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC)
-{
- __GLcontext *result;
- __GLcontext *sharectx = (__GLcontext *)shareGC;
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaCreateContext\n");
-
- result = (__GLcontext *)calloc(1, sizeof(__GLcontext));
- if (!result) return NULL;
-
- result->interface.imports = *imports;
- result->interface.exports = glAquaExports;
-
- result->pixelFormat = makeFormat(mode);
- if (!result->pixelFormat) {
- free(result);
- return NULL;
- }
-
- result->ctx = NULL;
- gl_err = CGLCreateContext(result->pixelFormat,
- sharectx ? sharectx->ctx : NULL,
- &result->ctx);
-
- if (gl_err != 0) {
- ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
- CGLDestroyPixelFormat(result->pixelFormat);
- free(result);
- return NULL;
- }
-
- GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
- return (__GLinterface *)result;
-}
-
-Bool
-glAquaRealizeWindow(WindowPtr pWin)
-{
- // If this window has GL contexts, tell them to reattach
- Bool result;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
- __GLXdrawablePrivate *glxPriv;
-
- GLAQUA_DEBUG_MSG("glAquaRealizeWindow\n");
-
- // Allow the window to be created (RootlessRealizeWindow is inside our wrap)
- pScreen->RealizeWindow = screenPriv->RealizeWindow;
- result = pScreen->RealizeWindow(pWin);
- pScreen->RealizeWindow = glAquaRealizeWindow;
-
- // The Aqua window will already have been created (windows are
- // realized from top down)
-
- // Re-attach this window's GL contexts, if any.
- glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
- if (glxPriv) {
- __GLXcontext *gx;
- __GLcontext *gc;
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
- GLAQUA_DEBUG_MSG("glAquaRealizeWindow is GL drawable!\n");
-
- // GL contexts bound to this window for drawing
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
-
- // GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- attach(gc, glPriv);
- }
- }
-
- return result;
-}
-
-Bool
-glAquaUnrealizeWindow(WindowPtr pWin)
-{
- // If this window has GL contexts, tell them to unattach
- Bool result;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- glAquaScreenRec *screenPriv = &glAquaScreens[pScreen->myNum];
- __GLXdrawablePrivate *glxPriv;
-
- GLAQUA_DEBUG_MSG("glAquaUnrealizeWindow\n");
-
- // The Aqua window may have already been destroyed (windows
- // are unrealized from top down)
-
- // Unattach this window's GL contexts, if any.
- glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
- if (glxPriv) {
- __GLXcontext *gx;
- __GLcontext *gc;
- GLAQUA_DEBUG_MSG("glAquaUnealizeWindow is GL drawable!\n");
-
- // GL contexts bound to this window for drawing
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- unattach(gc);
- }
-
- // GL contexts bound to this window for reading
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- unattach(gc);
- }
- }
-
- pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow;
- result = pScreen->UnrealizeWindow(pWin);
- pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
-
- return result;
-}
-
-
-// Originally copied from Mesa
-
-static int numConfigs = 0;
-static __GLXvisualConfig *visualConfigs = NULL;
-static void **visualPrivates = NULL;
-
-/*
- * 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 __GLXvisualConfig NullConfig = {
- -1, /* vid */
- -1, /* class */
- False, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- False, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
-};
-
-
-static inline int count_bits(uint32_t x)
-{
- x = x - ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x = x + (x >> 8);
- x = x + (x >> 16);
- return x & 63;
-}
-
-
-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;
-
- GLAQUA_DEBUG_MSG("init_visuals\n");
-
- 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++) {
- int count;
-
- count = ((pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor)
- ? numRGBconfigs : numCIconfigs);
- if (count == 0)
- count = 1; /* preserve the existing visual */
-
- numNewVisuals += count;
- }
-
- /* 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;
- glAquaScreens[screenInfo.numScreens-1].modes = modes;
- for (i = j = 0; i < numVisuals; i++) {
- int is_rgb = (pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor);
-
- if (!is_rgb)
- {
- /* We don't support non-rgb visuals for GL. But we don't
- want to remove them either, so just pass them through
- with null glX configs */
-
- 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, & NullConfig );
- modes->visualID = pVisualNew[j].vid;
-
- j++;
-
- continue;
- }
-
- 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 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 */
- glAquaScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- glAquaScreens[screenInfo.numScreens-1].priv = 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)
- xfree(visualPrivates);
- visualPrivates = NULL;
-
- return TRUE;
-}
-
-/* based on code in i830_dri.c
- This ends calling glAquaSetVisualConfigs to set the static
- numconfigs, etc. */
-static void
-glAquaInitVisualConfigs(void)
-{
- int lclNumConfigs = 0;
- __GLXvisualConfig *lclVisualConfigs = NULL;
- void **lclVisualPrivates = NULL;
-
- int depth, aux, buffers, stencil, accum;
- int i = 0;
-
- GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs ");
-
- /* count num configs:
- 2 Z buffer (0, 24 bit)
- 2 AUX buffer (0, 2)
- 2 buffers (single, double)
- 2 stencil (0, 8 bit)
- 2 accum (0, 64 bit)
- = 32 configs */
-
- lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
-
- /* alloc */
- lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
- lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
-
- /* fill in configs */
- if (NULL != lclVisualConfigs) {
- i = 0; /* current buffer */
- for (depth = 0; depth < 2; depth++) {
- for (aux = 0; aux < 2; aux++) {
- for (buffers = 0; buffers < 2; buffers++) {
- for (stencil = 0; stencil < 2; stencil++) {
- for (accum = 0; accum < 2; accum++) {
- lclVisualConfigs[i].vid = -1;
- lclVisualConfigs[i].class = -1;
- lclVisualConfigs[i].rgba = TRUE;
- lclVisualConfigs[i].redSize = -1;
- lclVisualConfigs[i].greenSize = -1;
- lclVisualConfigs[i].blueSize = -1;
- lclVisualConfigs[i].redMask = -1;
- lclVisualConfigs[i].greenMask = -1;
- lclVisualConfigs[i].blueMask = -1;
- lclVisualConfigs[i].alphaMask = 0;
- if (accum) {
- lclVisualConfigs[i].accumRedSize = 16;
- lclVisualConfigs[i].accumGreenSize = 16;
- lclVisualConfigs[i].accumBlueSize = 16;
- lclVisualConfigs[i].accumAlphaSize = 16;
- }
- else {
- lclVisualConfigs[i].accumRedSize = 0;
- lclVisualConfigs[i].accumGreenSize = 0;
- lclVisualConfigs[i].accumBlueSize = 0;
- lclVisualConfigs[i].accumAlphaSize = 0;
- }
- lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
- lclVisualConfigs[i].stereo = FALSE;
- lclVisualConfigs[i].bufferSize = -1;
-
- lclVisualConfigs[i].depthSize = depth? 24 : 0;
- lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
- lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
- lclVisualConfigs[i].level = 0;
- lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
- lclVisualConfigs[i].transparentPixel = 0;
- lclVisualConfigs[i].transparentRed = 0;
- lclVisualConfigs[i].transparentGreen = 0;
- lclVisualConfigs[i].transparentBlue = 0;
- lclVisualConfigs[i].transparentAlpha = 0;
- lclVisualConfigs[i].transparentIndex = 0;
- i++;
- }
- }
- }
- }
- }
- }
- if (i != lclNumConfigs)
- GLAQUA_DEBUG_MSG("glAquaInitVisualConfigs failed to alloc visual configs");
-
- GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
-}
-
-
-static void glAquaSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates)
-{
- GLAQUA_DEBUG_MSG("glAquaSetVisualConfigs\n");
-
- numConfigs = nconfigs;
- visualConfigs = configs;
- visualPrivates = privates;
-}
-
-static Bool glAquaInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB)
-{
- GLAQUA_DEBUG_MSG("glAquaInitVisuals\n");
-
- if (numConfigs == 0) /* if no configs */
- glAquaInitVisualConfigs(); /* ensure the visual configs are setup */
-
- /*
- * Setup the visuals supported by this particular screen.
- */
- return init_visuals(nvisualp, visualp, defaultVisp,
- *ndepthp, *depthp, *rootDepthp);
-}
-
-
-static void fixup_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- glAquaScreenRec *pScr = &glAquaScreens[screen];
- int j;
- __GLcontextModes *modes;
-
- GLAQUA_DEBUG_MSG("fixup_visuals\n");
-
- for ( modes = pScr->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);
- }
- }
- }
-}
-
-static void init_screen_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- __GLcontextModes *modes;
- int *used;
- int i, j;
-
- GLAQUA_DEBUG_MSG("init_screen_visuals\n");
-
- /* 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
- * FIXME: than 64 or 128 the stack array can be used instead of calling
- * 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));
-
- i = 0;
- for ( modes = glAquaScreens[screen].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;
-
- for (j = 0; j < pScreen->numVisuals; j++) {
- if (pVis[j].class == vis_class &&
- pVis[j].nplanes == nplanes &&
- pVis[j].redMask == modes->redMask &&
- pVis[j].greenMask == modes->greenMask &&
- pVis[j].blueMask == modes->blueMask &&
- !used[j]) {
-
- /* Set the VisualID */
- modes->visualID = pVis[j].vid;
-
- /* Mark this visual used */
- used[j] = 1;
- break;
- }
- }
- if ( j == pScreen->numVisuals ) {
- ErrorF("No matching visual for __GLcontextMode with "
- "visual class = %d (%d), nplanes = %u\n",
- vis_class,
- (int)modes->visualType,
- (unsigned int)(modes->rgbBits - modes->alphaBits) );
- }
- else if ( modes->visualID == -1 ) {
- FatalError( "Matching visual found, but visualID still -1!\n" );
- }
-
- i++;
- }
-
- __glXFree(used);
-}
-
-static Bool glAquaScreenProbe(int screen)
-{
- ScreenPtr pScreen;
- glAquaScreenRec *screenPriv;
-
- GLAQUA_DEBUG_MSG("glAquaScreenProbe\n");
-
- /*
- * Set up the current screen's visuals.
- */
- __glDDXScreenInfo.modes = glAquaScreens[screen].modes;
- __glDDXScreenInfo.pVisualPriv = glAquaScreens[screen].priv;
- __glDDXScreenInfo.numVisuals =
- __glDDXScreenInfo.numUsableVisuals = glAquaScreens[screen].num_vis;
-
- /*
- * Set the current screen's createContext routine. This could be
- * wrapped by a DDX GLX context creation routine.
- */
- __glDDXScreenInfo.createContext = glAquaCreateContext;
-
- /*
- * The ordering of the rgb compenents might have been changed by the
- * driver after mi initialized them.
- */
- fixup_visuals(screen);
-
- /*
- * Find the GLX visuals that are supported by this screen and create
- * XMesa's visuals.
- */
- init_screen_visuals(screen);
-
- /*
- * Wrap RealizeWindow and UnrealizeWindow on this screen
- */
- pScreen = screenInfo.screens[screen];
- screenPriv = &glAquaScreens[screen];
- screenPriv->RealizeWindow = pScreen->RealizeWindow;
- pScreen->RealizeWindow = glAquaRealizeWindow;
- screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
- pScreen->UnrealizeWindow = glAquaUnrealizeWindow;
-
- return TRUE;
-}
-
-static GLboolean glAquaSwapBuffers(__GLXdrawablePrivate *glxPriv)
-{
- // swap buffers on only *one* of the contexts
- // (e.g. the last one for drawing)
- __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc;
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaSwapBuffers\n");
-
- if (gc != NULL && gc->ctx != NULL)
- {
- gl_err = CGLFlushDrawable(gc->ctx);
- if (gl_err != 0)
- ErrorF("CGLFlushDrawable error: %s\n", CGLErrorString(gl_err));
- }
-
- return GL_TRUE;
-}
-
-static void glAquaDestroyDrawablePrivate(__GLdrawablePrivate *glPriv)
-{
- GLAQUA_DEBUG_MSG("glAquaDestroyDrawablePrivate\n");
-
- /* It doesn't work to call DRIDestroySurface here, the drawable's
- already gone.. But dri.c notices the window destruction and
- frees the surface itself. */
-
- free(glPriv->private);
- glPriv->private = NULL;
-}
-
-static void glAquaCreateBuffer(__GLXdrawablePrivate *glxPriv)
-{
- GLAquaDrawableRec *aquaPriv = malloc(sizeof(GLAquaDrawableRec));
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
-
- aquaPriv->sid = 0;
- aquaPriv->pDraw = NULL;
-
- GLAQUA_DEBUG_MSG("glAquaCreateBuffer\n");
-
- // replace swapBuffers (original is never called)
- glxPriv->swapBuffers = glAquaSwapBuffers;
-
- // stash private data
- glPriv->private = aquaPriv;
- glPriv->freePrivate = glAquaDestroyDrawablePrivate;
-}
-
-static void glAquaResetExtension(void)
-{
- GLAQUA_DEBUG_MSG("glAquaResetExtension\n");
- CGLSetOption(kCGLGOResetLibrary, GL_TRUE);
-}
-
-// Extra goodies for glx
-
-GLuint __glFloorLog2(GLuint val)
-{
- int c = 0;
-
- while (val > 1) {
- c++;
- val >>= 1;
- }
- return c;
-}
diff --git a/nx-X11/programs/Xserver/GL/dri/Imakefile b/nx-X11/programs/Xserver/GL/dri/Imakefile
deleted file mode 100644
index 8ea938f8c..000000000
--- a/nx-X11/programs/Xserver/GL/dri/Imakefile
+++ /dev/null
@@ -1,35 +0,0 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/dri/Imakefile,v 1.6 2001/04/28 13:55:36 dawes Exp $
-
-#define IHaveModules
-#include <Server.tmpl>
-
-#if DoLoadableServer
-MSRC = drimodule.c
-MOBJ = drimodule.o
-#endif
-
- SRCS = xf86dri.c dri.c $(MSRC)
- OBJS = xf86dri.o dri.o $(MOBJ)
-
- INCLUDES = -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(XINCLUDESRC) \
- -I$(EXTINCSRC) -I$(MESASRCDIR)/include \
- -I$(XF86OSSRC) -I$(XF86COMSRC) \
- -I../include -I../glx -I$(LIBSRC)/GL/include \
- -I$(DRMSRCDIR)/shared-core \
- -I$(SERVERSRC)/mi -I$(FONTINCSRC)
- DEFINES = $(GLX_DEFINES)
-
-LinkSourceFile(xf86dri.h,$(MESASRCDIR)/src/glx/x11)
-LinkSourceFile(xf86dristr.h,$(MESASRCDIR)/src/glx/x11)
-
-ModuleObjectRule()
-LibraryModuleTarget(dri,$(OBJS))
-InstallLibraryModule(dri,$(MODULEDIR),extensions)
-
-DependTarget()
-
-InstallDriverSDKLibraryModule(dri,$(DRIVERSDKMODULEDIR),extensions)
-
-InstallDriverSDKNonExecFile(dri.h,$(DRIVERSDKINCLUDEDIR))
-InstallDriverSDKNonExecFile(sarea.h,$(DRIVERSDKINCLUDEDIR))
-InstallDriverSDKNonExecFile(xf86dri.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference b/nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference
deleted file mode 100644
index 59fb0af84..000000000
--- a/nx-X11/programs/Xserver/GL/dri/Imakefile.NX.reference
+++ /dev/null
@@ -1,35 +0,0 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/dri/Imakefile,v 1.7 2003/02/11 21:34:04 tsi Exp $
-
-#define IHaveModules
-#include <Server.tmpl>
-
-#if DoLoadableServer
-MSRC = drimodule.c
-MOBJ = drimodule.o
-#endif
-
- SRCS = xf86dri.c dri.c $(MSRC)
- OBJS = xf86dri.o dri.o $(MOBJ)
-
- INCLUDES = -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(XINCLUDESRC) \
- -I$(EXTINCSRC) \
- -I$(XF86OSSRC) -I$(XF86COMSRC) \
- -I../include -I../glx -I$(LIBSRC)/GL/include \
- -I$(SERVERSRC)/mi -I$(FONTINCSRC) \
- -I../../hw/xfree86/os-support/bus
- DEFINES = $(GLX_DEFINES)
-
-LinkSourceFile(xf86dri.h,$(LIBSRC)/GL/dri)
-LinkSourceFile(xf86dristr.h,$(LIBSRC)/GL/dri)
-
-ModuleObjectRule()
-LibraryModuleTarget(dri,$(OBJS))
-InstallLibraryModule(dri,$(MODULEDIR),extensions)
-
-DependTarget()
-
-InstallDriverSDKLibraryModule(dri,$(DRIVERSDKMODULEDIR),extensions)
-
-InstallDriverSDKNonExecFile(dri.h,$(DRIVERSDKINCLUDEDIR))
-InstallDriverSDKNonExecFile(sarea.h,$(DRIVERSDKINCLUDEDIR))
-InstallDriverSDKNonExecFile(xf86dri.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference b/nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference
deleted file mode 100644
index c8770f6d8..000000000
--- a/nx-X11/programs/Xserver/GL/dri/Imakefile.XF86.reference
+++ /dev/null
@@ -1,34 +0,0 @@
-XCOMM $XFree86: xc/programs/Xserver/GL/dri/Imakefile,v 1.7 2003/02/11 21:34:04 tsi Exp $
-
-#define IHaveModules
-#include <Server.tmpl>
-
-#if DoLoadableServer
-MSRC = drimodule.c
-MOBJ = drimodule.o
-#endif
-
- SRCS = xf86dri.c dri.c $(MSRC)
- OBJS = xf86dri.o dri.o $(MOBJ)
-
- INCLUDES = -I$(SERVERSRC)/include -I$(INCLUDESRC) -I$(XINCLUDESRC) \
- -I$(EXTINCSRC) \
- -I$(XF86OSSRC) -I$(XF86COMSRC) \
- -I../include -I../glx -I$(LIBSRC)/GL/include \
- -I$(SERVERSRC)/mi -I$(FONTINCSRC)
- DEFINES = $(GLX_DEFINES)
-
-LinkSourceFile(xf86dri.h,$(LIBSRC)/GL/dri)
-LinkSourceFile(xf86dristr.h,$(LIBSRC)/GL/dri)
-
-ModuleObjectRule()
-LibraryModuleTarget(dri,$(OBJS))
-InstallLibraryModule(dri,$(MODULEDIR),extensions)
-
-DependTarget()
-
-InstallDriverSDKLibraryModule(dri,$(DRIVERSDKMODULEDIR),extensions)
-
-InstallDriverSDKNonExecFile(dri.h,$(DRIVERSDKINCLUDEDIR))
-InstallDriverSDKNonExecFile(sarea.h,$(DRIVERSDKINCLUDEDIR))
-InstallDriverSDKNonExecFile(xf86dri.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/nx-X11/programs/Xserver/GL/dri/dri-def.cpp b/nx-X11/programs/Xserver/GL/dri/dri-def.cpp
deleted file mode 100644
index 0d1ab6872..000000000
--- a/nx-X11/programs/Xserver/GL/dri/dri-def.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-LIBRARY DRI
-VERSION LIBRARY_VERSION
-EXPORTS
-
-XFree86DRIExtensionInit
-DRIAuthConnection
-DRIBlockHandler
-DRIClipNotify
-DRICloseConnection
-DRICloseScreen
-DRIContextPrivDelete
-DRICopyWindow
-DRICreateContext
-DRICreateContextPriv
-DRICreateContextPrivFromHandle
-DRICreateDrawable
-DRICreateInfoRec
-DRIDestroyContext
-DRIDestroyContextPriv
-DRIDestroyDrawable
-DRIDestroyInfoRec
-DRIDoBlockHandler
-DRIDoWakeupHandler
-DRIDrawablePrivDelete
-DRIExtensionInit
-DRIFinishScreenInit
-DRIGetClientDriverName
-DRIGetContext
-DRIGetContextStore
-DRIGetDeviceInfo
-DRIGetDrawableIndex
-DRIGetDrawableInfo
-DRIGetDrawableStamp
-DRIGetSAREAPrivate
-DRIGetWrappedFuncs
-DRILock
-DRIOpenConnection
-DRIPaintWindow
-DRIPostValidateTree
-DRIPrintDrawableLock
-DRIQueryDirectRenderingCapable
-DRIQueryVersion
-DRIReset
-DRIScreenInit
-DRISwapContext
-DRIUnlock
-DRIValidateTree
-DRIWakeupHandler
-
-/* $XFree86$ */
diff --git a/nx-X11/programs/Xserver/GL/dri/dri.c b/nx-X11/programs/Xserver/GL/dri/dri.c
deleted file mode 100644
index 424a21c68..000000000
--- a/nx-X11/programs/Xserver/GL/dri/dri.c
+++ /dev/null
@@ -1,2109 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.39 2003/11/10 18:21:41 tsi Exp $ */
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@tungstengraphics.com>
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#ifdef XFree86LOADER
-#include "xf86_ansic.h"
-#else
-#include <sys/time.h>
-#include <unistd.h>
-#endif
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#define _XF86DRI_SERVER_
-#include "xf86dristr.h"
-#include "swaprep.h"
-#include "xf86str.h"
-#include "dri.h"
-#include "sarea.h"
-#include "dristruct.h"
-#include "xf86.h"
-#include "xf86drm.h"
-#include "glxserver.h"
-#include "mi.h"
-#include "mipointer.h"
-
-#if defined(XFree86LOADER) && !defined(PANORAMIX)
-extern Bool noPanoramiXExtension;
-#endif
-
-static int DRIScreenPrivIndex = -1;
-static int DRIWindowPrivIndex = -1;
-static unsigned long DRIGeneration = 0;
-static unsigned int DRIDrawableValidationStamp = 0;
-
-static RESTYPE DRIDrawablePrivResType;
-static RESTYPE DRIContextPrivResType;
-static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
-
- /* Wrapper just like xf86DrvMsg, but
- without the verbosity level checking.
- This will make it easy to turn off some
- messages later, based on verbosity
- level. */
-
-/*
- * Since we're already referencing things from the XFree86 common layer in
- * this file, we'd might as well just call xf86VDrvMsgVerb, and have
- * consistent message formatting. The verbosity of these messages can be
- * easily changed here.
- */
-#define DRI_MSG_VERBOSITY 1
-static void
-DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- xf86VDrvMsgVerb(scrnIndex, type, DRI_MSG_VERBOSITY, format, ap);
- va_end(ap);
-}
-
-Bool
-DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
-{
- DRIScreenPrivPtr pDRIPriv;
- drm_context_t * reserved;
- int reserved_count;
- int i, fd, drmWasAvailable;
- Bool xineramaInCore = FALSE;
- int err = 0;
- char *openbusid;
- drmVersionPtr drmlibv;
- int drmlibmajor, drmlibminor, drmdimajor, drmdiminor;
-
- if (DRIGeneration != serverGeneration) {
- if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DRIGeneration = serverGeneration;
- }
-
- /* If the DRI extension is disabled, do not initialize the DRI */
- if (noXFree86DRIExtension) {
- DRIDrvMsg(pScreen->myNum, X_WARNING,
- "Direct rendering has been disabled.\n");
- return FALSE;
- }
-
- /*
- * If Xinerama is on, don't allow DRI to initialise. It won't be usable
- * anyway.
- */
-#if defined(PANORAMIX) && !defined(XFree86LOADER)
- xineramaInCore = TRUE;
-#elif defined(XFree86LOADER)
- if (xf86LoaderCheckSymbol("noPanoramiXExtension"))
- xineramaInCore = TRUE;
-#endif
-
-#if defined(PANORAMIX) || defined(XFree86LOADER)
- if (xineramaInCore) {
- if (!noPanoramiXExtension) {
- DRIDrvMsg(pScreen->myNum, X_WARNING,
- "Direct rendering is not supported when Xinerama is enabled\n");
- return FALSE;
- }
- }
-#endif
-
- drmWasAvailable = drmAvailable();
-
- /* Check the DRM lib version.
- * drmGetLibVersion was not supported in version 1.0, so check for
- * symbol first to avoid possible crash or hang.
- */
- drmlibmajor = 1;
- drmlibminor = 0;
- if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
- drmlibv = drmGetLibVersion(-1);
- if (drmlibv != NULL) {
- drmlibmajor = drmlibv->version_major;
- drmlibminor = drmlibv->version_minor;
- drmFreeVersion(drmlibv);
- }
- }
-
- /* Check if the libdrm can handle falling back to loading based on name
- * if a busid string is passed.
- */
- if (drmlibmajor == 1 && drmlibminor >= 2)
- openbusid = pDRIInfo->busIdString;
- else
- openbusid = NULL;
-
- /* Note that drmOpen will try to load the kernel module, if needed. */
- fd = drmOpen(pDRIInfo->drmDriverName, openbusid);
- if (fd < 0) {
- /* failed to open DRM */
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmOpen failed\n");
- return FALSE;
- }
-
- if (!drmWasAvailable) {
- /* drmOpen loaded the kernel module, print a message to say so */
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] loaded kernel module for \"%s\" driver\n",
- pDRIInfo->drmDriverName);
- }
-
- pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
- if (!pDRIPriv) {
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- return FALSE;
- }
-
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
- pDRIPriv->drmFD = fd;
- pDRIPriv->directRenderingSupport = TRUE;
- pDRIPriv->pDriverInfo = pDRIInfo;
- pDRIPriv->nrWindows = 0;
- pDRIPriv->fullscreen = NULL;
-
- pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx;
- pDRIPriv->createDummyCtxPriv = pDRIInfo->createDummyCtxPriv;
-
- pDRIPriv->grabbedDRILock = FALSE;
- pDRIPriv->drmSIGIOHandlerInstalled = FALSE;
-
- if (drmlibmajor == 1 && drmlibminor >= 2) {
- drmSetVersion sv;
-
- /* Get the interface version, asking for 1.1. */
- sv.drm_di_major = 1;
- sv.drm_di_minor = 1;
- sv.drm_dd_major = -1;
- err = drmSetInterfaceVersion(pDRIPriv->drmFD, &sv);
- if (err == 0) {
- drmdimajor = sv.drm_di_major;
- drmdiminor = sv.drm_di_minor;
- } else {
- /* failure, so set it to 1.0.0. */
- drmdimajor = 1;
- drmdiminor = 0;
- }
- }
- else {
- /* We can't check the DI DRM interface version, so set it to 1.0.0. */
- drmdimajor = 1;
- drmdiminor = 0;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] DRM interface version %d.%d\n", drmdimajor, drmdiminor);
-
- /* If the interface minor number is 1.1, then we've opened a DRM device
- * that already had the busid set through drmOpen.
- */
- if (drmdimajor == 1 && drmdiminor >= 1)
- err = 0;
- else
- err = drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString);
-
- if (err < 0) {
- pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmSetBusid failed (%d, %s), %s\n",
- pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString, strerror(-err));
- return FALSE;
- }
-
- *pDRMFD = pDRIPriv->drmFD;
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] created \"%s\" driver at busid \"%s\"\n",
- pDRIPriv->pDriverInfo->drmDriverName,
- pDRIPriv->pDriverInfo->busIdString);
-
- if (drmAddMap( pDRIPriv->drmFD,
- 0,
- pDRIPriv->pDriverInfo->SAREASize,
- DRM_SHM,
- DRM_CONTAINS_LOCK,
- &pDRIPriv->hSAREA) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmAddMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] added %d byte SAREA at %p\n",
- pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
-
- if (drmMap( pDRIPriv->drmFD,
- pDRIPriv->hSAREA,
- pDRIPriv->pDriverInfo->SAREASize,
- (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmMap failed\n");
- return FALSE;
- }
- memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
- pDRIPriv->hSAREA, pDRIPriv->pSAREA);
-
- if (drmAddMap( pDRIPriv->drmFD,
- (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
- pDRIPriv->pDriverInfo->frameBufferSize,
- DRM_FRAME_BUFFER,
- 0,
- &pDRIPriv->hFrameBuffer) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmAddMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
- pDRIPriv->hFrameBuffer);
-
- /* Add tags for reserved contexts */
- if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
- &reserved_count))) {
- int i;
- void *tag;
-
- for (i = 0; i < reserved_count; i++) {
- tag = DRICreateContextPrivFromHandle(pScreen,
- reserved[i],
- DRI_CONTEXT_RESERVED);
- drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
- }
- drmFreeReservedContextList(reserved);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] added %d reserved context%s for kernel\n",
- reserved_count, reserved_count > 1 ? "s" : "");
- }
-
- /* validate max drawable table entry set by driver */
- if ((pDRIPriv->pDriverInfo->maxDrawableTableEntry <= 0) ||
- (pDRIPriv->pDriverInfo->maxDrawableTableEntry > SAREA_MAX_DRAWABLES)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "Invalid max drawable table size set by driver: %d\n",
- pDRIPriv->pDriverInfo->maxDrawableTableEntry);
- }
-
- /* Initialize drawable tables (screen private and SAREA) */
- for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
- pDRIPriv->DRIDrawables[i] = NULL;
- pDRIPriv->pSAREA->drawableTable[i].stamp = 0;
- pDRIPriv->pSAREA->drawableTable[i].flags = 0;
- }
-
- return TRUE;
-}
-
-Bool
-DRIFinishScreenInit(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
- DRIContextFlags flags = 0;
- DRIContextPrivPtr pDRIContextPriv;
-
- /* Set up flags for DRICreateContextPriv */
- switch (pDRIInfo->driverSwapMethod) {
- case DRI_KERNEL_SWAP: flags = DRI_CONTEXT_2DONLY; break;
- case DRI_HIDE_X_CONTEXT: flags = DRI_CONTEXT_PRESERVED; break;
- }
-
- if (!(pDRIContextPriv = DRICreateContextPriv(pScreen,
- &pDRIPriv->myContext,
- flags))) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to create server context\n");
- return FALSE;
- }
- pDRIPriv->myContextPriv = pDRIContextPriv;
-
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "X context handle = %p\n", pDRIPriv->myContext);
-
- /* Now that we have created the X server's context, we can grab the
- * hardware lock for the X server.
- */
- DRILock(pScreen, 0);
- pDRIPriv->grabbedDRILock = TRUE;
-
- /* pointers so that we can prevent memory leaks later */
- pDRIPriv->hiddenContextStore = NULL;
- pDRIPriv->partial3DContextStore = NULL;
-
- switch(pDRIInfo->driverSwapMethod) {
- case DRI_HIDE_X_CONTEXT:
- /* Server will handle 3D swaps, and hide 2D swaps from kernel.
- * Register server context as a preserved context.
- */
-
- /* allocate memory for hidden context store */
- pDRIPriv->hiddenContextStore
- = (void *)xcalloc(1, pDRIInfo->contextSize);
- if (!pDRIPriv->hiddenContextStore) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to allocate hidden context\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
-
- /* allocate memory for partial 3D context store */
- pDRIPriv->partial3DContextStore
- = (void *)xcalloc(1, pDRIInfo->contextSize);
- if (!pDRIPriv->partial3DContextStore) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] failed to allocate partial 3D context\n");
- xfree(pDRIPriv->hiddenContextStore);
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
-
- /* save initial context store */
- if (pDRIInfo->SwapContext) {
- (*pDRIInfo->SwapContext)(
- pScreen,
- DRI_NO_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore,
- DRI_NO_CONTEXT,
- NULL);
- }
- /* fall through */
-
- case DRI_SERVER_SWAP:
- /* For swap methods of DRI_SERVER_SWAP and DRI_HIDE_X_CONTEXT
- * setup signal handler for receiving swap requests from kernel
- */
- if (!(pDRIPriv->drmSIGIOHandlerInstalled =
- drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to setup DRM signal handler\n");
- if (pDRIPriv->hiddenContextStore)
- xfree(pDRIPriv->hiddenContextStore);
- if (pDRIPriv->partial3DContextStore)
- xfree(pDRIPriv->partial3DContextStore);
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- } else {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] installed DRM signal handler\n");
- }
-
- default:
- break;
- }
-
- /* Wrap DRI support */
- if (pDRIInfo->wrap.ValidateTree) {
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree;
- }
- if (pDRIInfo->wrap.PostValidateTree) {
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree;
- }
- if (pDRIInfo->wrap.WindowExposures) {
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures;
- }
- if (pDRIInfo->wrap.CopyWindow) {
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow;
- }
- if (pDRIInfo->wrap.ClipNotify) {
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
- }
- if (pDRIInfo->wrap.AdjustFrame) {
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
- pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
- }
- pDRIPriv->wrapped = TRUE;
-
- DRIDrvMsg(pScreen->myNum, X_INFO, "[DRI] installation complete\n");
-
- return TRUE;
-}
-
-void
-DRICloseScreen(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo;
- drm_context_t * reserved;
- int reserved_count;
-
- if (pDRIPriv && pDRIPriv->directRenderingSupport) {
-
- pDRIInfo = pDRIPriv->pDriverInfo;
-
- if (pDRIPriv->wrapped) {
- /* Unwrap DRI Functions */
- if (pDRIInfo->wrap.ValidateTree) {
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
- pDRIPriv->wrap.ValidateTree = NULL;
- }
- if (pDRIInfo->wrap.PostValidateTree) {
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
- pDRIPriv->wrap.PostValidateTree = NULL;
- }
- if (pDRIInfo->wrap.WindowExposures) {
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
- pDRIPriv->wrap.WindowExposures = NULL;
- }
- if (pDRIInfo->wrap.CopyWindow) {
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
- pDRIPriv->wrap.CopyWindow = NULL;
- }
- if (pDRIInfo->wrap.ClipNotify) {
- pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
- pDRIPriv->wrap.ClipNotify = NULL;
- }
- if (pDRIInfo->wrap.AdjustFrame) {
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
- pDRIPriv->wrap.AdjustFrame = NULL;
- }
- pDRIPriv->wrapped = FALSE;
- }
-
- if (pDRIPriv->drmSIGIOHandlerInstalled) {
- if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to remove DRM signal handler\n");
- }
- }
-
- if (pDRIPriv->dummyCtxPriv && pDRIPriv->createDummyCtx) {
- DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv);
- }
-
- if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to destroy server context\n");
- }
-
- /* Remove tags for reserved contexts */
- if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
- &reserved_count))) {
- int i;
-
- for (i = 0; i < reserved_count; i++) {
- DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
- reserved[i]));
- }
- drmFreeReservedContextList(reserved);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] removed %d reserved context%s for kernel\n",
- reserved_count, reserved_count > 1 ? "s" : "");
- }
-
- /* Make sure signals get unblocked etc. */
- drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
- pDRIPriv->lockRefCount = 0;
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] unmapping %d bytes of SAREA %p at %p\n",
- pDRIInfo->SAREASize,
- pDRIPriv->hSAREA,
- pDRIPriv->pSAREA);
- if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] unable to unmap %d bytes"
- " of SAREA %p at %p\n",
- pDRIInfo->SAREASize,
- pDRIPriv->hSAREA,
- pDRIPriv->pSAREA);
- }
-
- drmClose(pDRIPriv->drmFD);
-
- xfree(pDRIPriv);
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- }
-}
-
-Bool
-DRIExtensionInit(void)
-{
- int i;
- ScreenPtr pScreen;
-
- if (DRIScreenPrivIndex < 0) {
- return FALSE;
- }
-
- /* Allocate a window private index with a zero sized private area for
- * each window, then should a window become a DRI window, we'll hang
- * a DRIWindowPrivateRec off of this private index.
- */
- if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
-
- DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
- DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete);
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- pScreen = screenInfo.screens[i];
- if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0))
- return FALSE;
- }
-
- RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
-
- return TRUE;
-}
-
-void
-DRIReset(void)
-{
- /*
- * This stub routine is called when the X Server recycles, resources
- * allocated by DRIExtensionInit need to be managed here.
- *
- * Currently this routine is a stub because all the interesting resources
- * are managed via the screen init process.
- */
-}
-
-Bool
-DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv)
- *isCapable = pDRIPriv->directRenderingSupport;
- else
- *isCapable = FALSE;
-
- return TRUE;
-}
-
-Bool
-DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- *hSAREA = pDRIPriv->hSAREA;
- *busIdString = pDRIPriv->pDriverInfo->busIdString;
-
- return TRUE;
-}
-
-Bool
-DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
- return TRUE;
-}
-
-Bool
-DRICloseConnection(ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-Bool
-DRIGetClientDriverName(ScreenPtr pScreen,
- int *ddxDriverMajorVersion,
- int *ddxDriverMinorVersion,
- int *ddxDriverPatchVersion,
- char **clientDriverName)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- *ddxDriverMajorVersion = pDRIPriv->pDriverInfo->ddxDriverMajorVersion;
- *ddxDriverMinorVersion = pDRIPriv->pDriverInfo->ddxDriverMinorVersion;
- *ddxDriverPatchVersion = pDRIPriv->pDriverInfo->ddxDriverPatchVersion;
- *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName;
-
- return TRUE;
-}
-
-/* DRICreateContextPriv and DRICreateContextPrivFromHandle are helper
- functions that layer on drmCreateContext and drmAddContextTag.
-
- DRICreateContextPriv always creates a kernel drm_context_t and then calls
- DRICreateContextPrivFromHandle to create a DRIContextPriv structure for
- DRI tracking. For the SIGIO handler, the drm_context_t is associated with
- DRIContextPrivPtr. Any special flags are stored in the DRIContextPriv
- area and are passed to the kernel (if necessary).
-
- DRICreateContextPriv returns a pointer to newly allocated
- DRIContextPriv, and returns the kernel drm_context_t in pHWContext. */
-
-DRIContextPrivPtr
-DRICreateContextPriv(ScreenPtr pScreen,
- drm_context_t * pHWContext,
- DRIContextFlags flags)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (drmCreateContext(pDRIPriv->drmFD, pHWContext)) {
- return NULL;
- }
-
- return DRICreateContextPrivFromHandle(pScreen, *pHWContext, flags);
-}
-
-DRIContextPrivPtr
-DRICreateContextPrivFromHandle(ScreenPtr pScreen,
- drm_context_t hHWContext,
- DRIContextFlags flags)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIContextPrivPtr pDRIContextPriv;
- int contextPrivSize;
-
- contextPrivSize = sizeof(DRIContextPrivRec) +
- pDRIPriv->pDriverInfo->contextSize;
- if (!(pDRIContextPriv = xcalloc(1, contextPrivSize))) {
- return NULL;
- }
- pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1);
-
- drmAddContextTag(pDRIPriv->drmFD, hHWContext, pDRIContextPriv);
-
- pDRIContextPriv->hwContext = hHWContext;
- pDRIContextPriv->pScreen = pScreen;
- pDRIContextPriv->flags = flags;
- pDRIContextPriv->valid3D = FALSE;
-
- if (flags & DRI_CONTEXT_2DONLY) {
- if (drmSetContextFlags(pDRIPriv->drmFD,
- hHWContext,
- DRM_CONTEXT_2DONLY)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to set 2D context flag\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return NULL;
- }
- }
- if (flags & DRI_CONTEXT_PRESERVED) {
- if (drmSetContextFlags(pDRIPriv->drmFD,
- hHWContext,
- DRM_CONTEXT_PRESERVED)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to set preserved flag\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return NULL;
- }
- }
- return pDRIContextPriv;
-}
-
-Bool
-DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv)
-{
- DRIScreenPrivPtr pDRIPriv;
-
- if (!pDRIContextPriv) return TRUE;
-
- pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
-
- if (!(pDRIContextPriv->flags & DRI_CONTEXT_RESERVED)) {
- /* Don't delete reserved contexts from
- kernel area -- the kernel manages its
- reserved contexts itself. */
- if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext))
- return FALSE;
- }
-
- /* Remove the tag last to prevent a race
- condition where the context has pending
- buffers. The context can't be re-used
- while in this thread, but buffers can be
- dispatched asynchronously. */
- drmDelContextTag(pDRIPriv->drmFD, pDRIContextPriv->hwContext);
- xfree(pDRIContextPriv);
- return TRUE;
-}
-
-static Bool
-DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum);
- __GLcontextModes *modes = pGLXScreen->modes;
- void **pVisualConfigPriv = pGLXScreen->pVisualPriv;
- DRIContextPrivPtr pDRIContextPriv;
- void *contextStore;
- VisualPtr visual;
- int visNum;
-
- visual = pScreen->visuals;
-
- /* Find the X visual that corresponds the the first GLX visual */
- for (visNum = 0;
- visNum < pScreen->numVisuals;
- visNum++, visual++) {
- if (modes->visualID == visual->vid)
- break;
- }
- if (visNum == pScreen->numVisuals) return FALSE;
-
- if (!(pDRIContextPriv =
- DRICreateContextPriv(pScreen,
- &pDRIPriv->pSAREA->dummy_context, 0))) {
- return FALSE;
- }
-
- contextStore = DRIGetContextStore(pDRIContextPriv);
- if (pDRIPriv->pDriverInfo->CreateContext && needCtxPriv) {
- if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, visual,
- pDRIPriv->pSAREA->dummy_context,
- *pVisualConfigPriv,
- (DRIContextType)(long)contextStore)) {
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
- }
-
- pDRIPriv->dummyCtxPriv = pDRIContextPriv;
- return TRUE;
-}
-
-static void
-DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIContextPrivPtr pDRIContextPriv = pDRIPriv->dummyCtxPriv;
- void *contextStore;
-
- if (!pDRIContextPriv) return;
- if (pDRIPriv->pDriverInfo->DestroyContext && hasCtxPriv) {
- contextStore = DRIGetContextStore(pDRIContextPriv);
- pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
- pDRIContextPriv->hwContext,
- (DRIContextType)(long)contextStore);
- }
-
- DRIDestroyContextPriv(pDRIPriv->dummyCtxPriv);
- pDRIPriv->dummyCtxPriv = NULL;
-}
-
-Bool
-DRICreateContext(ScreenPtr pScreen, VisualPtr visual,
- XID context, drm_context_t * pHWContext)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- __GLXscreenInfo *pGLXScreen = __glXgetActiveScreen(pScreen->myNum);
- __GLcontextModes *modes = pGLXScreen->modes;
- void **pVisualConfigPriv = pGLXScreen->pVisualPriv;
- DRIContextPrivPtr pDRIContextPriv;
- void *contextStore;
-
- if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) {
- if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] Could not create dummy context\n");
- return FALSE;
- }
- }
-
- /* Find the GLX visual associated with the one requested */
- for (modes = pGLXScreen->modes; modes != NULL; modes = modes->next) {
- if (modes->visualID == visual->vid)
- break;
- pVisualConfigPriv++;
- }
-
- if (modes == NULL) {
- /* No matching GLX visual found */
- return FALSE;
- }
-
- if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, pHWContext, 0))) {
- return FALSE;
- }
-
- contextStore = DRIGetContextStore(pDRIContextPriv);
- if (pDRIPriv->pDriverInfo->CreateContext) {
- if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, visual,
- *pHWContext, *pVisualConfigPriv,
- (DRIContextType)(long)contextStore))) {
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
- }
-
- /* track this in case the client dies before cleanup */
- AddResource(context, DRIContextPrivResType, (pointer)pDRIContextPriv);
-
- return TRUE;
-}
-
-Bool
-DRIDestroyContext(ScreenPtr pScreen, XID context)
-{
- FreeResourceByType(context, DRIContextPrivResType, FALSE);
-
- return TRUE;
-}
-
-/* DRIContextPrivDelete is called by the resource manager. */
-Bool
-DRIContextPrivDelete(pointer pResource, XID id)
-{
- DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource;
- DRIScreenPrivPtr pDRIPriv;
- void *contextStore;
-
- pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
- if (pDRIPriv->pDriverInfo->DestroyContext) {
- contextStore = DRIGetContextStore(pDRIContextPriv);
- pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
- pDRIContextPriv->hwContext,
- (DRIContextType)(long)contextStore);
- }
- return DRIDestroyContextPriv(pDRIContextPriv);
-}
-
-
-/* This walks the drawable timestamp array and invalidates all of them
- * in the case of transition from private to shared backbuffers. It's
- * not necessary for correctness, because DRIClipNotify gets called in
- * time to prevent any conflict, but the transition from
- * shared->private is sometimes missed if we don't do this.
- */
-static void
-DRIClipNotifyAllDrawables(ScreenPtr pScreen)
-{
- int i;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
- pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++;
- }
-}
-
-
-static void
-DRITransitionToSharedBuffers(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionSingleToMulti3D)
- pDRIInfo->TransitionSingleToMulti3D( pScreen );
-}
-
-
-static void
-DRITransitionToPrivateBuffers(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionMultiToSingle3D)
- pDRIInfo->TransitionMultiToSingle3D( pScreen );
-}
-
-
-static void
-DRITransitionTo3d(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionTo3d)
- pDRIInfo->TransitionTo3d( pScreen );
-}
-
-static void
-DRITransitionTo2d(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionTo2d)
- pDRIInfo->TransitionTo2d( pScreen );
-}
-
-
-Bool
-DRICreateDrawable(ScreenPtr pScreen, Drawable id,
- DrawablePtr pDrawable, drm_drawable_t * hHWDrawable)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
- WindowPtr pWin;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- pDRIDrawablePriv->refCount++;
- }
- else {
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = xalloc(sizeof(DRIDrawablePrivRec)))) {
- return FALSE;
- }
-
- /* Only create a drm_drawable_t once */
- if (drmCreateDrawable(pDRIPriv->drmFD, hHWDrawable)) {
- xfree(pDRIDrawablePriv);
- return FALSE;
- }
-
- /* add it to the list of DRI drawables for this screen */
- pDRIDrawablePriv->hwDrawable = *hHWDrawable;
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 1;
- pDRIDrawablePriv->drawableIndex = -1;
-
- /* save private off of preallocated index */
- pWin->devPrivates[DRIWindowPrivIndex].ptr =
- (pointer)pDRIDrawablePriv;
-
- switch (++pDRIPriv->nrWindows) {
- case 1:
- DRITransitionTo3d( pScreen );
- break;
- case 2:
- DRITransitionToSharedBuffers( pScreen );
- break;
- default:
- break;
- }
-
- /* track this in case this window is destroyed */
- AddResource(id, DRIDrawablePrivResType, (pointer)pWin);
- }
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool
-DRIDestroyDrawable(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv;
- WindowPtr pWin;
-
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- pDRIDrawablePriv->refCount--;
- if (pDRIDrawablePriv->refCount <= 0) {
- /* This calls back DRIDrawablePrivDelete which frees private area */
- FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
- }
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool
-DRIDrawablePrivDelete(pointer pResource, XID id)
-{
- DrawablePtr pDrawable = (DrawablePtr)pResource;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
- WindowPtr pWin;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if (pDRIDrawablePriv->drawableIndex != -1) {
- /* bump stamp to force outstanding 3D requests to resync */
- pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
- = DRIDrawableValidationStamp++;
-
- /* release drawable table entry */
- pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
- }
-
- if (drmDestroyDrawable(pDRIPriv->drmFD,
- pDRIDrawablePriv->hwDrawable)) {
- return FALSE;
- }
- xfree(pDRIDrawablePriv);
- pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
-
- switch (--pDRIPriv->nrWindows) {
- case 0:
- DRITransitionTo2d( pDrawable->pScreen );
- break;
- case 1:
- DRITransitionToPrivateBuffers( pDrawable->pScreen );
- break;
- default:
- break;
- }
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool
-DRIGetDrawableInfo(ScreenPtr pScreen,
- DrawablePtr pDrawable,
- unsigned int* index,
- unsigned int* stamp,
- int* X,
- int* Y,
- int* W,
- int* H,
- int* numClipRects,
- drm_clip_rect_t ** pClipRects,
- int* backX,
- int* backY,
- int* numBackClipRects,
- drm_clip_rect_t ** pBackClipRects)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv;
- WindowPtr pWin, pOldWin;
- int i;
-
- printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry);
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
-
- /* Manage drawable table */
- if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */
-
- /* Search table for empty entry */
- i = 0;
- while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
- if (!(pDRIPriv->DRIDrawables[i])) {
- pDRIPriv->DRIDrawables[i] = pDrawable;
- pDRIDrawablePriv->drawableIndex = i;
- pDRIPriv->pSAREA->drawableTable[i].stamp =
- DRIDrawableValidationStamp++;
- break;
- }
- i++;
- }
-
- /* Search table for oldest entry */
- if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
- unsigned int oldestStamp = ~0;
- int oldestIndex = 0;
- i = pDRIPriv->pDriverInfo->maxDrawableTableEntry;
- while (i--) {
- if (pDRIPriv->pSAREA->drawableTable[i].stamp <
- oldestStamp) {
- oldestIndex = i;
- oldestStamp =
- pDRIPriv->pSAREA->drawableTable[i].stamp;
- }
- }
- pDRIDrawablePriv->drawableIndex = oldestIndex;
-
- /* release oldest drawable table entry */
- pOldWin = (WindowPtr)pDRIPriv->DRIDrawables[oldestIndex];
- pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin);
- pOldDrawPriv->drawableIndex = -1;
-
- /* claim drawable table entry */
- pDRIPriv->DRIDrawables[oldestIndex] = pDrawable;
-
- /* validate SAREA entry */
- pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp =
- DRIDrawableValidationStamp++;
-
- /* check for stamp wrap around */
- if (oldestStamp > DRIDrawableValidationStamp) {
-
- /* walk SAREA table and invalidate all drawables */
- for( i=0;
- i < pDRIPriv->pDriverInfo->maxDrawableTableEntry;
- i++) {
- pDRIPriv->pSAREA->drawableTable[i].stamp =
- DRIDrawableValidationStamp++;
- }
- }
- }
-
- /* If the driver wants to be notified when the index is
- * set for a drawable, let it know now.
- */
- if (pDRIPriv->pDriverInfo->SetDrawableIndex)
- pDRIPriv->pDriverInfo->SetDrawableIndex(pWin,
- pDRIDrawablePriv->drawableIndex);
-
- /* reinit drawable ID if window is visible */
- if ((pWin->viewable) &&
- (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS))
- {
- (*pDRIPriv->pDriverInfo->InitBuffers)(pWin,
- &pWin->clipList, pDRIDrawablePriv->drawableIndex);
- }
- }
-
- *index = pDRIDrawablePriv->drawableIndex;
- *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp;
- *X = (int)(pWin->drawable.x);
- *Y = (int)(pWin->drawable.y);
-#if 0
- *W = (int)(pWin->winSize.extents.x2 - pWin->winSize.extents.x1);
- *H = (int)(pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
-#endif
- *W = (int)(pWin->drawable.width);
- *H = (int)(pWin->drawable.height);
- *numClipRects = REGION_NUM_RECTS(&pWin->clipList);
- *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList);
-
- if (!*numClipRects && pDRIPriv->fullscreen) {
- /* use fake full-screen clip rect */
- pDRIPriv->fullscreen_rect.x1 = *X;
- pDRIPriv->fullscreen_rect.y1 = *Y;
- pDRIPriv->fullscreen_rect.x2 = *X + *W;
- pDRIPriv->fullscreen_rect.y2 = *Y + *H;
-
- *numClipRects = 1;
- *pClipRects = &pDRIPriv->fullscreen_rect;
- }
-
- *backX = *X;
- *backY = *Y;
-
- if (pDRIPriv->nrWindows == 1 && *numClipRects) {
- /* Use a single cliprect. */
-
- int x0 = *X;
- int y0 = *Y;
- int x1 = x0 + *W;
- int y1 = y0 + *H;
-
- if (x0 < 0) x0 = 0;
- if (y0 < 0) y0 = 0;
- if (x1 > pScreen->width) x1 = pScreen->width;
- if (y1 > pScreen->height) y1 = pScreen->height;
-
- pDRIPriv->private_buffer_rect.x1 = x0;
- pDRIPriv->private_buffer_rect.y1 = y0;
- pDRIPriv->private_buffer_rect.x2 = x1;
- pDRIPriv->private_buffer_rect.y2 = y1;
-
- *numBackClipRects = 1;
- *pBackClipRects = &(pDRIPriv->private_buffer_rect);
- } else {
- /* Use the frontbuffer cliprects for back buffers. */
- *numBackClipRects = 0;
- *pBackClipRects = 0;
- }
- }
- else {
- /* Not a DRIDrawable */
- return FALSE;
- }
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool
-DRIGetDeviceInfo(ScreenPtr pScreen,
- drm_handle_t * hFrameBuffer,
- int* fbOrigin,
- int* fbSize,
- int* fbStride,
- int* devPrivateSize,
- void** pDevPrivate)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- *hFrameBuffer = pDRIPriv->hFrameBuffer;
- *fbOrigin = 0;
- *fbSize = pDRIPriv->pDriverInfo->frameBufferSize;
- *fbStride = pDRIPriv->pDriverInfo->frameBufferStride;
- *devPrivateSize = pDRIPriv->pDriverInfo->devPrivateSize;
- *pDevPrivate = pDRIPriv->pDriverInfo->devPrivate;
-
- return TRUE;
-}
-
-DRIInfoPtr
-DRICreateInfoRec(void)
-{
- DRIInfoPtr inforec = (DRIInfoPtr)xcalloc(1, sizeof(DRIInfoRec));
- if (!inforec) return NULL;
-
- /* Initialize defaults */
- inforec->busIdString = NULL;
-
- /* Wrapped function defaults */
- inforec->wrap.WakeupHandler = DRIDoWakeupHandler;
- inforec->wrap.BlockHandler = DRIDoBlockHandler;
- inforec->wrap.WindowExposures = DRIWindowExposures;
- inforec->wrap.CopyWindow = DRICopyWindow;
- inforec->wrap.ValidateTree = DRIValidateTree;
- inforec->wrap.PostValidateTree = DRIPostValidateTree;
- inforec->wrap.ClipNotify = DRIClipNotify;
- inforec->wrap.AdjustFrame = DRIAdjustFrame;
-
- inforec->TransitionTo2d = 0;
- inforec->TransitionTo3d = 0;
- inforec->SetDrawableIndex = 0;
-
- return inforec;
-}
-
-void
-DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
-{
- if (DRIInfo->busIdString) xfree(DRIInfo->busIdString);
- xfree((char*)DRIInfo);
-}
-
-
-void
-DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask)
-{
- int i;
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv &&
- pDRIPriv->pDriverInfo->wrap.WakeupHandler)
- (*pDRIPriv->pDriverInfo->wrap.WakeupHandler)(i, wakeupData,
- result, pReadmask);
- }
-}
-
-void
-DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
-{
- int i;
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv &&
- pDRIPriv->pDriverInfo->wrap.BlockHandler)
- (*pDRIPriv->pDriverInfo->wrap.BlockHandler)(i, blockData,
- pTimeout, pReadmask);
- }
-}
-
-void
-DRIDoWakeupHandler(int screenNum, pointer wakeupData,
- unsigned long result, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- DRILock(pScreen, 0);
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_3D_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore);
- }
-}
-
-void
-DRIDoBlockHandler(int screenNum, pointer blockData,
- pointer pTimeout, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_NO_CONTEXT,
- NULL,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore);
- }
- DRIUnlock(pScreen);
-}
-
-void
-DRISwapContext(int drmFD, void *oldctx, void *newctx)
-{
- DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx;
- DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx;
- ScreenPtr pScreen = newContext->pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- void* oldContextStore = NULL;
- DRIContextType oldContextType;
- void* newContextStore = NULL;
- DRIContextType newContextType;
- DRISyncType syncType;
-#ifdef DEBUG
- static int count = 0;
-#endif
-
- if (!newContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n",
- oldContext, newContext);
- return;
- }
-
-#ifdef DEBUG
- /* usefull for debugging, just print out after n context switches */
- if (!count || !(count % 1)) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[DRI] Context switch %5d from %p/0x%08x (%d)\n",
- count,
- oldContext,
- oldContext ? oldContext->flags : 0,
- oldContext ? oldContext->hwContext : -1);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[DRI] Context switch %5d to %p/0x%08x (%d)\n",
- count,
- newContext,
- newContext ? newContext->flags : 0,
- newContext ? newContext->hwContext : -1);
- }
- ++count;
-#endif
-
- if (!pDRIPriv->pDriverInfo->SwapContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] DDX driver missing context swap call back\n");
- return;
- }
-
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
-
- /* only 3D contexts are swapped in this case */
- if (oldContext) {
- oldContextStore = DRIGetContextStore(oldContext);
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- } else {
- oldContextType = DRI_NO_CONTEXT;
- }
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_3D_SYNC;
- }
- else /* default: driverSwapMethod == DRI_SERVER_SWAP */ {
-
- /* optimize 2D context swaps */
-
- if (newContext->flags & DRI_CONTEXT_2DONLY) {
- /* go from 3D context to 2D context and only save 2D
- * subset of 3D state
- */
- oldContextStore = DRIGetContextStore(oldContext);
- oldContextType = DRI_2D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- newContextType = DRI_2D_CONTEXT;
- syncType = DRI_3D_SYNC;
- pDRIPriv->lastPartial3DContext = oldContext;
- }
- else if (oldContext->flags & DRI_CONTEXT_2DONLY) {
- if (pDRIPriv->lastPartial3DContext == newContext) {
- /* go from 2D context back to previous 3D context and
- * only restore 2D subset of previous 3D state
- */
- oldContextStore = DRIGetContextStore(oldContext);
- oldContextType = DRI_2D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- newContextType = DRI_2D_CONTEXT;
- syncType = DRI_2D_SYNC;
- }
- else {
- /* go from 2D context to a different 3D context */
-
- /* call DDX driver to do partial restore */
- oldContextStore = DRIGetContextStore(oldContext);
- newContextStore =
- DRIGetContextStore(pDRIPriv->lastPartial3DContext);
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_2D_CONTEXT,
- oldContextStore,
- DRI_2D_CONTEXT,
- newContextStore);
-
- /* now setup for a complete 3D swap */
- oldContextStore = newContextStore;
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_NO_SYNC;
- }
- }
- else {
- /* now setup for a complete 3D swap */
- oldContextStore = newContextStore;
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_3D_SYNC;
- }
- }
-
- /* call DDX driver to perform the swap */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- syncType,
- oldContextType,
- oldContextStore,
- newContextType,
- newContextStore);
-}
-
-void*
-DRIGetContextStore(DRIContextPrivPtr context)
-{
- return((void *)context->pContextStore);
-}
-
-void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if(pDRIDrawablePriv) {
- (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, prgn,
- pDRIDrawablePriv->drawableIndex);
- }
-
- /* call lower wrapped functions */
- if (pDRIPriv && pDRIPriv->wrap.WindowExposures) {
-
- /* unwrap */
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
-
- /* call lower layers */
- (*pScreen->WindowExposures)(pWin, prgn, bsreg);
-
- /* rewrap */
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = DRIWindowExposures;
- }
-}
-
-
-static int
-DRITreeTraversal(WindowPtr pWin, pointer data)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if(pDRIDrawablePriv) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- RegionPtr reg = (RegionPtr)data;
-
- REGION_UNION(pScreen, reg, reg, &(pWin->clipList));
-
- if(pDRIPriv->nrWindows == 1)
- return WT_STOPWALKING;
- }
- return WT_WALKCHILDREN;
-}
-
-void
-DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if(!pDRIPriv) return;
-
- if(pDRIPriv->nrWindows > 0) {
- RegionRec reg;
-
- REGION_NULL(pScreen, &reg);
- TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
-
- if(REGION_NOTEMPTY(pScreen, &reg)) {
- REGION_TRANSLATE(pScreen, &reg, ptOldOrg.x - pWin->drawable.x,
- ptOldOrg.y - pWin->drawable.y);
- REGION_INTERSECT(pScreen, &reg, &reg, prgnSrc);
-
- /* The MoveBuffers interface is not ideal */
- (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, &reg,
- pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
- }
-
- REGION_UNINIT(pScreen, &reg);
- }
-
- /* call lower wrapped functions */
- if(pDRIPriv->wrap.CopyWindow) {
- /* unwrap */
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
-
- /* call lower layers */
- (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
- /* rewrap */
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = DRICopyWindow;
- }
-}
-
-static void
-DRIGetSecs(long *secs, long *usecs)
-{
-#ifdef XFree86LOADER
- getsecs(secs,usecs);
-#else
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- *secs = tv.tv_sec;
- *usecs = tv.tv_usec;
-#endif
-}
-
-static unsigned long
-DRIComputeMilliSeconds(unsigned long s_secs, unsigned long s_usecs,
- unsigned long f_secs, unsigned long f_usecs)
-{
- if (f_usecs < s_usecs) {
- --f_secs;
- f_usecs += 1000000;
- }
- return (f_secs - s_secs) * 1000 + (f_usecs - s_usecs) / 1000;
-}
-
-static void
-DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */)
-{
- int count = 10000;
-#if !defined(__alpha__) && !defined(__powerpc__)
- char ret;
-#else
- int ret;
-#endif
- long s_secs, s_usecs;
- long f_secs, f_usecs;
- long msecs;
- long prev = 0;
-
- DRIGetSecs(&s_secs, &s_usecs);
-
- do {
- DRM_SPINLOCK_COUNT(lock, val, count, ret);
- if (!ret) return; /* Got lock */
- DRIGetSecs(&f_secs, &f_usecs);
- msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs);
- if (msecs - prev < 250) count *= 2; /* Not more than 0.5S */
- } while (msecs < timeout);
-
- /* Didn't get lock, so take it. The worst
- that can happen is that there is some
- garbage written to the wrong part of the
- framebuffer that a refresh will repair.
- That's undesirable, but better than
- locking the server. This should be a
- very rare event. */
- DRM_SPINLOCK_TAKE(lock, val);
-}
-
-static void
-DRILockTree(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if(!pDRIPriv) return;
-
- /* Restore the last known 3D context if the X context is hidden */
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_NO_CONTEXT,
- NULL,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore);
- }
-
- /* Call kernel to release lock */
- DRIUnlock(pScreen);
-
- /* Grab drawable spin lock: a time out between 10 and 30 seconds is
- appropriate, since this should never time out except in the case of
- client death while the lock is being held. The timeout must be
- greater than any reasonable rendering time. */
- DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs*/
-
- /* Call kernel flush outstanding buffers and relock */
- DRILock(pScreen, DRM_LOCK_QUIESCENT|DRM_LOCK_FLUSH_ALL);
-
- /* Switch back to our 2D context if the X context is hidden */
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_3D_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore);
- }
-}
-
-/* It appears that somebody is relying on the lock being set even
- if we aren't touching 3D windows */
-
-#define DRI_BROKEN
-
-static Bool DRIWindowsTouched = FALSE;
-
-int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen = pParent->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- int returnValue = 1; /* always return 1, not checked by dix/window.c */
-
- if(!pDRIPriv) return returnValue;
-
- DRIWindowsTouched = FALSE;
-
-#ifdef DRI_BROKEN
- if(!DRIWindowsTouched) {
- DRILockTree(pScreen);
- DRIWindowsTouched = TRUE;
- }
-#endif
-
- /* call lower wrapped functions */
- if(pDRIPriv->wrap.ValidateTree) {
- /* unwrap */
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
- /* call lower layers */
- returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
- }
-
- return returnValue;
-}
-
-void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen;
- DRIScreenPrivPtr pDRIPriv;
-
- if (pParent) {
- pScreen = pParent->drawable.pScreen;
- } else {
- pScreen = pChild->drawable.pScreen;
- }
- if(!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) return;
-
- if (pDRIPriv->wrap.PostValidateTree) {
- /* unwrap */
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
- /* call lower layers */
- (*pScreen->PostValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
- }
-
- if (DRIWindowsTouched) {
- /* Release spin lock */
- DRM_SPINUNLOCK(&pDRIPriv->pSAREA->drawable_lock, 1);
- DRIWindowsTouched = FALSE;
- }
-}
-
-void
-DRIClipNotify(WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if(!pDRIPriv) return;
-
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
-
-#ifndef DRI_BROKEN
- if(!DRIWindowsTouched) {
- DRILockTree(pScreen);
- DRIWindowsTouched = TRUE;
- }
-#endif
-
- pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
- = DRIDrawableValidationStamp++;
- }
-
- /* call lower wrapped functions */
- if(pDRIPriv->wrap.ClipNotify) {
-
- /* unwrap */
- pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
-
- /* call lower layers */
- (*pScreen->ClipNotify)(pWin, dx, dy);
-
- /* rewrap */
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = DRIClipNotify;
- }
-}
-
-CARD32
-DRIGetDrawableIndex(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- CARD32 index;
-
- if (pDRIDrawablePriv) {
- index = pDRIDrawablePriv->drawableIndex;
- }
- else {
- index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry;
- }
-
- return index;
-}
-
-unsigned int
-DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp;
-}
-
-
-void
-DRIPrintDrawableLock(ScreenPtr pScreen, char *msg)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock);
-}
-
-void
-DRILock(ScreenPtr pScreen, int flags)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(!pDRIPriv) return;
-
- if (!pDRIPriv->lockRefCount)
- DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext, flags);
- pDRIPriv->lockRefCount++;
-}
-
-void
-DRIUnlock(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(!pDRIPriv) return;
-
- if (pDRIPriv->lockRefCount > 0) {
- pDRIPriv->lockRefCount--;
- }
- else {
- ErrorF("DRIUnlock called when not locked\n");
- return;
- }
- if (!pDRIPriv->lockRefCount)
- DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext);
-}
-
-void *
-DRIGetSAREAPrivate(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (!pDRIPriv) return 0;
-
- return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec));
-}
-
-drm_context_t
-DRIGetContext(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (!pDRIPriv) return 0;
-
- return pDRIPriv->myContext;
-}
-
-/* This lets get at the unwrapped functions so that they can correctly
- * call the lowerlevel functions, and choose whether they will be
- * called at every level of recursion (eg in validatetree).
- */
-DRIWrappedFuncsRec *
-DRIGetWrappedFuncs(ScreenPtr pScreen)
-{
- return &(DRI_SCREEN_PRIV(pScreen)->wrap);
-}
-
-/* note that this returns the library version, not the protocol version */
-void
-DRIQueryVersion(int *majorVersion,
- int *minorVersion,
- int *patchVersion)
-{
- *majorVersion = DRIINFO_MAJOR_VERSION;
- *minorVersion = DRIINFO_MINOR_VERSION;
- *patchVersion = DRIINFO_PATCH_VERSION;
-}
-
-static void
-_DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y)
-{
- pDRIPriv->pSAREA->frame.x = x;
- pDRIPriv->pSAREA->frame.y = y;
- pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1;
- pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1;
-}
-
-void
-DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[scrnIndex];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int px, py;
-
- if (!pDRIPriv || !pDRIPriv->pSAREA) {
- DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n",
- pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL);
- return;
- }
-
- if (pDRIPriv->fullscreen) {
- /* Fix up frame */
- pScrn->frameX0 = pDRIPriv->pSAREA->frame.x;
- pScrn->frameY0 = pDRIPriv->pSAREA->frame.y;
- pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1;
- pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1;
-
- /* Fix up cursor */
- miPointerPosition(&px, &py);
- if (px < pScrn->frameX0) px = pScrn->frameX0;
- if (px > pScrn->frameX1) px = pScrn->frameX1;
- if (py < pScrn->frameY0) py = pScrn->frameY0;
- if (py > pScrn->frameY1) py = pScrn->frameY1;
- pScreen->SetCursorPosition(pScreen, px, py, TRUE);
- return;
- }
-
- if (pDRIPriv->wrap.AdjustFrame) {
- /* unwrap */
- pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
- /* call lower layers */
- (*pScrn->AdjustFrame)(scrnIndex, x, y, flags);
- /* rewrap */
- pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
- pScrn->AdjustFrame = DRIAdjustFrame;
- }
-
- _DRIAdjustFrame(pScrn, pDRIPriv, x, y);
-}
-
-/*
- * DRIMoveBuffersHelper swaps the regions rects in place leaving you
- * a region with the rects in the order that you need to blit them,
- * but it is possibly (likely) an invalid region afterwards. If you
- * need to use the region again for anything you have to call
- * REGION_VALIDATE on it, or better yet, save a copy first.
- */
-
-void
-DRIMoveBuffersHelper(
- ScreenPtr pScreen,
- int dx,
- int dy,
- int *xdir,
- int *ydir,
- RegionPtr reg
-)
-{
- BoxPtr extents, pbox, firstBox, lastBox;
- BoxRec tmpBox;
- int y, nbox;
-
- extents = REGION_EXTENTS(pScreen, reg);
- nbox = REGION_NUM_RECTS(reg);
- pbox = REGION_RECTS(reg);
-
- if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
- *ydir = -1;
- if(nbox > 1) {
- firstBox = pbox;
- lastBox = pbox + nbox - 1;
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
- }
- }
- } else *ydir = 1;
-
- if((dx > 0) && (dx < (extents->x2 - extents->x1))) {
- *xdir = -1;
- if(nbox > 1) {
- firstBox = lastBox = pbox;
- y = pbox->y1;
- while(--nbox) {
- pbox++;
- if(pbox->y1 == y) lastBox++;
- else {
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
- }
-
- firstBox = lastBox = pbox;
- y = pbox->y1;
- }
- }
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
- }
- }
- } else *xdir = 1;
-
-}
-
-char *
-DRICreatePCIBusID(pciVideoPtr PciInfo)
-{
- char *busID;
- int domain;
- PCITAG tag;
-
- busID = xalloc(20);
- if (busID == NULL)
- return NULL;
-
- tag = pciTag(PciInfo->bus, PciInfo->device, PciInfo->func);
- domain = xf86GetPciDomain(tag);
- snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", domain, PciInfo->bus,
- PciInfo->device, PciInfo->func);
- return busID;
-}
diff --git a/nx-X11/programs/Xserver/GL/dri/dri.h b/nx-X11/programs/Xserver/GL/dri/dri.h
deleted file mode 100644
index 312e8a8bb..000000000
--- a/nx-X11/programs/Xserver/GL/dri/dri.h
+++ /dev/null
@@ -1,345 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dri.h,v 1.18 2001/03/21 16:21:40 dawes Exp $ */
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@tungstengraphics.com>
- *
- */
-
-/* Prototypes for DRI functions */
-
-#ifndef _DRI_H_
-
-#include "scrnintstr.h"
-#include "xf86dri.h"
-
-typedef int DRISyncType;
-
-#define DRI_NO_SYNC 0
-#define DRI_2D_SYNC 1
-#define DRI_3D_SYNC 2
-
-typedef int DRIContextType;
-
-typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr;
-
-typedef enum _DRIContextFlags
-{
- DRI_CONTEXT_2DONLY = 0x01,
- DRI_CONTEXT_PRESERVED = 0x02,
- DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */
-} DRIContextFlags;
-
-#define DRI_NO_CONTEXT 0
-#define DRI_2D_CONTEXT 1
-#define DRI_3D_CONTEXT 2
-
-typedef int DRISwapMethod;
-
-#define DRI_HIDE_X_CONTEXT 0
-#define DRI_SERVER_SWAP 1
-#define DRI_KERNEL_SWAP 2
-
-typedef int DRIWindowRequests;
-
-#define DRI_NO_WINDOWS 0
-#define DRI_3D_WINDOWS_ONLY 1
-#define DRI_ALL_WINDOWS 2
-
-
-typedef void (*ClipNotifyPtr)( WindowPtr, int, int );
-typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags);
-
-
-/*
- * These functions can be wrapped by the DRI. Each of these have
- * generic default funcs (initialized in DRICreateInfoRec) and can be
- * overridden by the driver in its [driver]DRIScreenInit function.
- */
-typedef struct {
- ScreenWakeupHandlerProcPtr WakeupHandler;
- ScreenBlockHandlerProcPtr BlockHandler;
- WindowExposuresProcPtr WindowExposures;
- CopyWindowProcPtr CopyWindow;
- ValidateTreeProcPtr ValidateTree;
- PostValidateTreeProcPtr PostValidateTree;
- ClipNotifyProcPtr ClipNotify;
- AdjustFramePtr AdjustFrame;
-} DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
-
-
-/*
- * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned
- * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also
- * being used to version the XFree86-DRI protocol. Bugs #3066 and #3163
- * showed that this was inadequate. The DRIInfoRec structure is now versioned
- * by the DRIINFO_*_VERSION defines in this file. - ajax, 2005-05-18.
- *
- * Revision history:
- * 4.1.0 and earlier: DRIQueryVersion returns XF86DRI_*_VERSION.
- * 4.2.0: DRIQueryVersion begins returning DRIINFO_*_VERSION.
- * 5.0.0: frameBufferPhysicalAddress changed from CARD32 to pointer.
- */
-
-#define DRIINFO_MAJOR_VERSION 5
-#define DRIINFO_MINOR_VERSION 0
-#define DRIINFO_PATCH_VERSION 0
-
-typedef struct {
- /* driver call back functions
- *
- * New fields should be added at the end for backwards compatibility.
- * Bump the DRIINFO patch number to indicate bugfixes.
- * Bump the DRIINFO minor number to indicate new fields.
- * Bump the DRIINFO major number to indicate binary-incompatible changes.
- */
- Bool (*CreateContext)(ScreenPtr pScreen,
- VisualPtr visual,
- drm_context_t hHWContext,
- void* pVisualConfigPriv,
- DRIContextType context);
- void (*DestroyContext)(ScreenPtr pScreen,
- drm_context_t hHWContext,
- DRIContextType context);
- void (*SwapContext)(ScreenPtr pScreen,
- DRISyncType syncType,
- DRIContextType readContextType,
- void* readContextStore,
- DRIContextType writeContextType,
- void* writeContextStore);
- void (*InitBuffers)(WindowPtr pWin,
- RegionPtr prgn,
- CARD32 indx);
- void (*MoveBuffers)(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc,
- CARD32 indx);
- void (*TransitionTo3d)(ScreenPtr pScreen);
- void (*TransitionTo2d)(ScreenPtr pScreen);
-
- void (*SetDrawableIndex)(WindowPtr pWin, CARD32 indx);
- Bool (*OpenFullScreen)(ScreenPtr pScreen);
- Bool (*CloseFullScreen)(ScreenPtr pScreen);
-
- /* wrapped functions */
- DRIWrappedFuncsRec wrap;
-
- /* device info */
- char* drmDriverName;
- char* clientDriverName;
- char* busIdString;
- int ddxDriverMajorVersion;
- int ddxDriverMinorVersion;
- int ddxDriverPatchVersion;
- pointer frameBufferPhysicalAddress;
- long frameBufferSize;
- long frameBufferStride;
- long SAREASize;
- int maxDrawableTableEntry;
- int ddxDrawableTableEntry;
- long contextSize;
- DRISwapMethod driverSwapMethod;
- DRIWindowRequests bufferRequests;
- int devPrivateSize;
- void* devPrivate;
- Bool createDummyCtx;
- Bool createDummyCtxPriv;
-
- /* New with DRI version 4.1.0 */
- void (*TransitionSingleToMulti3D)(ScreenPtr pScreen);
- void (*TransitionMultiToSingle3D)(ScreenPtr pScreen);
-} DRIInfoRec, *DRIInfoPtr;
-
-
-extern Bool DRIScreenInit(ScreenPtr pScreen,
- DRIInfoPtr pDRIInfo,
- int *pDRMFD);
-
-extern void DRICloseScreen(ScreenPtr pScreen);
-
-extern Bool DRIExtensionInit(void);
-
-extern void DRIReset(void);
-
-extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen,
- Bool *isCapable);
-
-extern Bool DRIOpenConnection(ScreenPtr pScreen,
- drm_handle_t * hSAREA,
- char **busIdString);
-
-extern Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic);
-
-extern Bool DRICloseConnection(ScreenPtr pScreen);
-
-extern Bool DRIGetClientDriverName(ScreenPtr pScreen,
- int* ddxDriverMajorVersion,
- int* ddxDriverMinorVersion,
- int* ddxDriverPatchVersion,
- char** clientDriverName);
-
-extern Bool DRICreateContext(ScreenPtr pScreen,
- VisualPtr visual,
- XID context,
- drm_context_t * pHWContext);
-
-extern Bool DRIDestroyContext(ScreenPtr pScreen, XID context);
-
-extern Bool DRIContextPrivDelete(pointer pResource, XID id);
-
-extern Bool DRICreateDrawable(ScreenPtr pScreen,
- Drawable id,
- DrawablePtr pDrawable,
- drm_drawable_t * hHWDrawable);
-
-extern Bool DRIDestroyDrawable(ScreenPtr pScreen,
- Drawable id,
- DrawablePtr pDrawable);
-
-extern Bool DRIDrawablePrivDelete(pointer pResource,
- XID id);
-
-extern Bool DRIGetDrawableInfo(ScreenPtr pScreen,
- DrawablePtr pDrawable,
- unsigned int* indx,
- unsigned int* stamp,
- int* X,
- int* Y,
- int* W,
- int* H,
- int* numClipRects,
- drm_clip_rect_t ** pClipRects,
- int* backX,
- int* backY,
- int* numBackClipRects,
- drm_clip_rect_t ** pBackClipRects);
-
-extern Bool DRIGetDeviceInfo(ScreenPtr pScreen,
- drm_handle_t * hFrameBuffer,
- int* fbOrigin,
- int* fbSize,
- int* fbStride,
- int* devPrivateSize,
- void** pDevPrivate);
-
-extern DRIInfoPtr DRICreateInfoRec(void);
-
-extern void DRIDestroyInfoRec(DRIInfoPtr DRIInfo);
-
-extern Bool DRIFinishScreenInit(ScreenPtr pScreen);
-
-extern void DRIWakeupHandler(pointer wakeupData,
- int result,
- pointer pReadmask);
-
-extern void DRIBlockHandler(pointer blockData,
- OSTimePtr pTimeout,
- pointer pReadmask);
-
-extern void DRIDoWakeupHandler(int screenNum,
- pointer wakeupData,
- unsigned long result,
- pointer pReadmask);
-
-extern void DRIDoBlockHandler(int screenNum,
- pointer blockData,
- pointer pTimeout,
- pointer pReadmask);
-
-extern void DRISwapContext(int drmFD,
- void *oldctx,
- void *newctx);
-
-extern void *DRIGetContextStore(DRIContextPrivPtr context);
-
-extern void DRIWindowExposures(WindowPtr pWin,
- RegionPtr prgn,
- RegionPtr bsreg);
-
-extern void DRICopyWindow(WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc);
-
-extern int DRIValidateTree(WindowPtr pParent,
- WindowPtr pChild,
- VTKind kind);
-
-extern void DRIPostValidateTree(WindowPtr pParent,
- WindowPtr pChild,
- VTKind kind);
-
-extern void DRIClipNotify(WindowPtr pWin,
- int dx,
- int dy);
-
-extern CARD32 DRIGetDrawableIndex(WindowPtr pWin);
-
-extern void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg);
-
-extern void DRILock(ScreenPtr pScreen, int flags);
-
-extern void DRIUnlock(ScreenPtr pScreen);
-
-extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen);
-
-extern void *DRIGetSAREAPrivate(ScreenPtr pScreen);
-
-extern unsigned int DRIGetDrawableStamp(ScreenPtr pScreen,
- CARD32 drawable_index);
-
-extern DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen,
- drm_context_t * pHWContext,
- DRIContextFlags flags);
-
-extern DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen,
- drm_context_t hHWContext,
- DRIContextFlags flags);
-
-extern Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv);
-
-extern drm_context_t DRIGetContext(ScreenPtr pScreen);
-
-extern void DRIQueryVersion(int *majorVersion,
- int *minorVersion,
- int *patchVersion);
-
-extern void DRIAdjustFrame(int scrnIndex, int x, int y, int flags);
-
-extern void DRIMoveBuffersHelper(ScreenPtr pScreen,
- int dx,
- int dy,
- int *xdir,
- int *ydir,
- RegionPtr reg);
-
-extern char *DRICreatePCIBusID(pciVideoPtr PciInfo);
-
-#define _DRI_H_
-
-#endif
diff --git a/nx-X11/programs/Xserver/GL/dri/drimodule.c b/nx-X11/programs/Xserver/GL/dri/drimodule.c
deleted file mode 100644
index 922c6f40e..000000000
--- a/nx-X11/programs/Xserver/GL/dri/drimodule.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* $XdotOrg: xc/programs/Xserver/GL/dri/drimodule.c,v 1.6 2005/11/02 15:53:57 kem Exp $ */
-/**************************************************************************
-
-Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-/* $XFree86: xc/programs/Xserver/GL/dri/drimodule.c,v 1.5 2001/06/15 21:22:39 dawes Exp $ */
-
-/*
- * Authors:
- * Kevin E. Martin <kevin@precisioninsight.com>
- * Rickard E. Faith <faith@precisioninsight.com>
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-#include "globals.h"
-
-static MODULESETUPPROTO(driSetup);
-
-static XF86ModuleVersionInfo VersRec =
-{
- "dri",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-extern void XFree86DRIExtensionInit(INITARGS);
-#define _XF86DRI_SERVER_
-#include "xf86dristr.h"
-
-ExtensionModule XF86DRIExt =
-{
- XFree86DRIExtensionInit,
- XF86DRINAME,
- &noXFree86DRIExtension,
- NULL,
- NULL
-};
-
-static const char *drmSymbols[] = {
- "drmAddContextTag",
- "drmAddMap",
- "drmAuthMagic",
- "drmAvailable",
- "drmClose",
- "drmCreateContext",
- "drmCreateDrawable",
- "drmDelContextTag",
- "drmDestroyContext",
- "drmDestroyDrawable",
- "drmFreeReservedContextList",
- "drmGetContextTag",
- "drmGetLock",
- "drmGetReservedContextList",
- "drmInstallSIGIOHandler",
- "drmMap",
- "drmOpen",
- "drmRemoveSIGIOHandler",
- "drmSetBusid",
- "drmSetContextFlags",
- "drmUnlock",
- "drmUnmap",
- NULL
-};
-
-XF86ModuleData driModuleData = { &VersRec, driSetup, NULL };
-
-static pointer
-driSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- static Bool setupDone = FALSE;
- pointer drm = NULL;
-
- if (!setupDone) {
- setupDone = TRUE;
-
- drm =
- LoadSubModule(module, "drm", NULL, NULL, NULL, NULL, errmaj, errmin);
-
- if (!drm) {
- if (errmaj) *errmaj = LDR_NOSUBENT;
- }
- else {
- LoaderReqSymLists(drmSymbols, NULL);
- LoaderRefSymbols("noPanoramiXExtension", NULL);
- LoadExtension(&XF86DRIExt, FALSE);
- }
- } else {
- if (errmaj) *errmaj = LDR_ONCEONLY;
- }
- /* Need a non-NULL return value to indicate success */
- return drm;
-}
-
diff --git a/nx-X11/programs/Xserver/GL/dri/dristruct.h b/nx-X11/programs/Xserver/GL/dri/dristruct.h
deleted file mode 100644
index b47afba3a..000000000
--- a/nx-X11/programs/Xserver/GL/dri/dristruct.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/dristruct.h,v 1.12 2002/10/30 12:52:03 alanh Exp $ */
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@tungstengraphics.com>
- *
- */
-
-#ifndef DRI_STRUCT_H
-#define DRI_STRUCT_H
-
-#include "xf86drm.h"
-
-
-#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
- ((DRIWindowPrivIndex < 0) ? \
- NULL : \
- ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
-
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
- ((DRIPixmapPrivIndex < 0) ? \
- NULL : \
- ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIWindowPrivIndex].ptr)))
-
-typedef struct _DRIDrawablePrivRec
-{
- drm_drawable_t hwDrawable;
- int drawableIndex;
- ScreenPtr pScreen;
- int refCount;
-} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
-
-struct _DRIContextPrivRec
-{
- drm_context_t hwContext;
- ScreenPtr pScreen;
- Bool valid3D;
- DRIContextFlags flags;
- void** pContextStore;
-};
-
-#define DRI_SCREEN_PRIV(pScreen) \
- ((DRIScreenPrivIndex < 0) ? \
- NULL : \
- ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
-
-#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
-
-
-typedef struct _DRIScreenPrivRec
-{
- Bool directRenderingSupport;
- int drmFD; /* File descriptor for /dev/video/? */
- drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
- XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
- drm_handle_t hFrameBuffer; /* Handle to framebuffer, for mapping */
- drm_context_t myContext; /* DDX Driver's context */
- DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */
- DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
- void** hiddenContextStore; /* hidden X context */
- void** partial3DContextStore; /* parital 3D context */
- DRIInfoPtr pDriverInfo;
- int nrWindows;
- drm_clip_rect_t private_buffer_rect; /* management of private buffers */
- DrawablePtr fullscreen; /* pointer to fullscreen drawable */
- drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
- DRIWrappedFuncsRec wrap;
- DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
- DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
- Bool createDummyCtx;
- Bool createDummyCtxPriv;
- Bool grabbedDRILock;
- Bool drmSIGIOHandlerInstalled;
- Bool wrapped;
- int lockRefCount;
-} DRIScreenPrivRec, *DRIScreenPrivPtr;
-
-#endif /* DRI_STRUCT_H */
diff --git a/nx-X11/programs/Xserver/GL/dri/sarea.h b/nx-X11/programs/Xserver/GL/dri/sarea.h
deleted file mode 100644
index 77c16e0ef..000000000
--- a/nx-X11/programs/Xserver/GL/dri/sarea.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.11 2002/10/30 12:52:03 alanh Exp $ */
-/**
- * \file sarea.h
- * SAREA definitions.
- *
- * \author Kevin E. Martin <kevin@precisioninsight.com>
- * \author Jens Owen <jens@tungstengraphics.com>
- * \author Rickard E. (Rik) Faith <faith@valinux.com>
- */
-
-/*
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.11 2002/10/30 12:52:03 alanh Exp $ */
-
-#ifndef _SAREA_H_
-#define _SAREA_H_
-
-#include "xf86drm.h"
-
-/* SAREA area needs to be at least a page */
-#if defined(__alpha__)
-#define SAREA_MAX 0x2000
-#elif defined(__ia64__)
-#define SAREA_MAX 0x10000 /* 64kB */
-#else
-/* Intel 830M driver needs at least 8k SAREA */
-#define SAREA_MAX 0x2000
-#endif
-
-#define SAREA_MAX_DRAWABLES 256
-
-#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000
-
-/**
- * SAREA per drawable information.
- *
- * \sa _XF86DRISAREA.
- */
-typedef struct _XF86DRISAREADrawable {
- unsigned int stamp;
- unsigned int flags;
-} XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr;
-
-/**
- * SAREA frame information.
- *
- * \sa _XF86DRISAREA.
- */
-typedef struct _XF86DRISAREAFrame {
- unsigned int x;
- unsigned int y;
- unsigned int width;
- unsigned int height;
- unsigned int fullscreen;
-} XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr;
-
-/**
- * SAREA definition.
- */
-typedef struct _XF86DRISAREA {
- /** first thing is always the DRM locking structure */
- drmLock lock;
- /** \todo Use readers/writer lock for drawable_lock */
- drmLock drawable_lock;
- XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES];
- XF86DRISAREAFrameRec frame;
- drm_context_t dummy_context;
-} XF86DRISAREARec, *XF86DRISAREAPtr;
-
-#endif
diff --git a/nx-X11/programs/Xserver/GL/dri/xf86dri.c b/nx-X11/programs/Xserver/GL/dri/xf86dri.c
deleted file mode 100644
index 273ccda1b..000000000
--- a/nx-X11/programs/Xserver/GL/dri/xf86dri.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/* $XFree86: xc/programs/Xserver/GL/dri/xf86dri.c,v 1.12 2002/12/14 01:36:08 dawes Exp $ */
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Jens Owen <jens@tungstengraphics.com>
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#ifdef XFree86LOADER
-#include "xf86_ansic.h"
-#endif
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-#define _XF86DRI_SERVER_
-#include "xf86dristr.h"
-#include "swaprep.h"
-#include "xf86str.h"
-#include "dri.h"
-#include "sarea.h"
-#include "dristruct.h"
-#include "xf86.h"
-#include "xf86drm.h"
-
-static int DRIErrorBase;
-
-static DISPATCH_PROC(ProcXF86DRIQueryVersion);
-static DISPATCH_PROC(ProcXF86DRIQueryDirectRenderingCapable);
-static DISPATCH_PROC(ProcXF86DRIOpenConnection);
-static DISPATCH_PROC(ProcXF86DRICloseConnection);
-static DISPATCH_PROC(ProcXF86DRIGetClientDriverName);
-static DISPATCH_PROC(ProcXF86DRICreateContext);
-static DISPATCH_PROC(ProcXF86DRIDestroyContext);
-static DISPATCH_PROC(ProcXF86DRICreateDrawable);
-static DISPATCH_PROC(ProcXF86DRIDestroyDrawable);
-static DISPATCH_PROC(ProcXF86DRIGetDrawableInfo);
-static DISPATCH_PROC(ProcXF86DRIGetDeviceInfo);
-static DISPATCH_PROC(ProcXF86DRIDispatch);
-static DISPATCH_PROC(ProcXF86DRIAuthConnection);
-
-static DISPATCH_PROC(SProcXF86DRIQueryVersion);
-static DISPATCH_PROC(SProcXF86DRIDispatch);
-
-static void XF86DRIResetProc(ExtensionEntry* extEntry);
-
-static unsigned char DRIReqCode = 0;
-
-extern void XFree86DRIExtensionInit(void);
-
-void
-XFree86DRIExtensionInit(void)
-{
- ExtensionEntry* extEntry;
-
-#ifdef XF86DRI_EVENTS
- EventType = CreateNewResourceType(XF86DRIFreeEvents);
-#endif
-
- if (
- DRIExtensionInit() &&
-#ifdef XF86DRI_EVENTS
- EventType && ScreenPrivateIndex != -1 &&
-#endif
- (extEntry = AddExtension(XF86DRINAME,
- XF86DRINumberEvents,
- XF86DRINumberErrors,
- ProcXF86DRIDispatch,
- SProcXF86DRIDispatch,
- XF86DRIResetProc,
- StandardMinorOpcode))) {
- DRIReqCode = (unsigned char)extEntry->base;
- DRIErrorBase = extEntry->errorBase;
- }
-}
-
-/*ARGSUSED*/
-static void
-XF86DRIResetProc (
- ExtensionEntry* extEntry
-)
-{
- DRIReset();
-}
-
-static int
-ProcXF86DRIQueryVersion(
- register ClientPtr client
-)
-{
- xXF86DRIQueryVersionReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = XF86DRI_MAJOR_VERSION;
- rep.minorVersion = XF86DRI_MINOR_VERSION;
- rep.patchVersion = XF86DRI_PATCH_VERSION;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
- WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIQueryDirectRenderingCapable(
- register ClientPtr client
-)
-{
- xXF86DRIQueryDirectRenderingCapableReply rep;
- Bool isCapable;
-
- REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
- REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen],
- &isCapable)) {
- return BadValue;
- }
- rep.isCapable = isCapable;
-
- if (!LocalClient(client))
- rep.isCapable = 0;
-
- WriteToClient(client,
- sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIOpenConnection(
- register ClientPtr client
-)
-{
- xXF86DRIOpenConnectionReply rep;
- drm_handle_t hSAREA;
- char* busIdString;
-
- REQUEST(xXF86DRIOpenConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!DRIOpenConnection( screenInfo.screens[stuff->screen],
- &hSAREA,
- &busIdString)) {
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.busIdStringLength = 0;
- if (busIdString)
- rep.busIdStringLength = strlen(busIdString);
- rep.length = (SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
- ((rep.busIdStringLength + 3) & ~3)) >> 2;
-
- rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
-#if defined(LONG64) && !defined(__linux__)
- rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
-#else
- rep.hSAREAHigh = 0;
-#endif
-
- WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
- if (rep.busIdStringLength)
- WriteToClient(client, rep.busIdStringLength, busIdString);
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIAuthConnection(
- register ClientPtr client
-)
-{
- xXF86DRIAuthConnectionReply rep;
-
- REQUEST(xXF86DRIAuthConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.authenticated = 1;
-
- if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
- ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
- rep.authenticated = 0;
- }
- WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRICloseConnection(
- register ClientPtr client
-)
-{
- REQUEST(xXF86DRICloseConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- DRICloseConnection( screenInfo.screens[stuff->screen]);
-
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIGetClientDriverName(
- register ClientPtr client
-)
-{
- xXF86DRIGetClientDriverNameReply rep;
- char* clientDriverName;
-
- REQUEST(xXF86DRIGetClientDriverNameReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- DRIGetClientDriverName( screenInfo.screens[stuff->screen],
- (int *)&rep.ddxDriverMajorVersion,
- (int *)&rep.ddxDriverMinorVersion,
- (int *)&rep.ddxDriverPatchVersion,
- &clientDriverName);
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.clientDriverNameLength = 0;
- if (clientDriverName)
- rep.clientDriverNameLength = strlen(clientDriverName);
- rep.length = (SIZEOF(xXF86DRIGetClientDriverNameReply) -
- SIZEOF(xGenericReply) +
- ((rep.clientDriverNameLength + 3) & ~3)) >> 2;
-
- WriteToClient(client,
- sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
- if (rep.clientDriverNameLength)
- WriteToClient(client,
- rep.clientDriverNameLength,
- clientDriverName);
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRICreateContext(
- register ClientPtr client
-)
-{
- xXF86DRICreateContextReply rep;
- ScreenPtr pScreen;
- VisualPtr visual;
- int i;
-
- REQUEST(xXF86DRICreateContextReq);
- REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- pScreen = screenInfo.screens[stuff->screen];
- visual = pScreen->visuals;
-
- /* Find the requested X visual */
- for (i = 0; i < pScreen->numVisuals; i++, visual++)
- if (visual->vid == stuff->visual)
- break;
- if (i == pScreen->numVisuals) {
- /* No visual found */
- return BadValue;
- }
-
- if (!DRICreateContext( pScreen,
- visual,
- stuff->context,
- (drm_context_t *)&rep.hHWContext)) {
- return BadValue;
- }
-
- WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIDestroyContext(
- register ClientPtr client
-)
-{
- REQUEST(xXF86DRIDestroyContextReq);
- REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!DRIDestroyContext( screenInfo.screens[stuff->screen],
- stuff->context)) {
- return BadValue;
- }
-
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRICreateDrawable(
- ClientPtr client
-)
-{
- xXF86DRICreateDrawableReply rep;
- DrawablePtr pDrawable;
-
- REQUEST(xXF86DRICreateDrawableReq);
- REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
- (Drawable)stuff->drawable,
- client,
- SecurityReadAccess))) {
- return BadValue;
- }
-
- if (!DRICreateDrawable( screenInfo.screens[stuff->screen],
- (Drawable)stuff->drawable,
- pDrawable,
- (drm_drawable_t *)&rep.hHWDrawable)) {
- return BadValue;
- }
-
- WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIDestroyDrawable(
- register ClientPtr client
-)
-{
- REQUEST(xXF86DRIDestroyDrawableReq);
- DrawablePtr pDrawable;
- REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
- (Drawable)stuff->drawable,
- client,
- SecurityReadAccess))) {
- return BadValue;
- }
-
- if (!DRIDestroyDrawable( screenInfo.screens[stuff->screen],
- (Drawable)stuff->drawable,
- pDrawable)) {
- return BadValue;
- }
-
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIGetDrawableInfo(
- register ClientPtr client
-)
-{
- xXF86DRIGetDrawableInfoReply rep;
- DrawablePtr pDrawable;
- int X, Y, W, H;
- drm_clip_rect_t * pClipRects;
- drm_clip_rect_t * pBackClipRects;
- int backX, backY;
-
- REQUEST(xXF86DRIGetDrawableInfoReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- if (!(pDrawable = (DrawablePtr)SecurityLookupDrawable(
- (Drawable)stuff->drawable,
- client,
- SecurityReadAccess))) {
- return BadValue;
- }
-
- if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen],
- pDrawable,
- (unsigned int*)&rep.drawableTableIndex,
- (unsigned int*)&rep.drawableTableStamp,
- (int*)&X,
- (int*)&Y,
- (int*)&W,
- (int*)&H,
- (int*)&rep.numClipRects,
- &pClipRects,
- &backX,
- &backY,
- (int*)&rep.numBackClipRects,
- &pBackClipRects)) {
- return BadValue;
- }
-
- rep.drawableX = X;
- rep.drawableY = Y;
- rep.drawableWidth = W;
- rep.drawableHeight = H;
- rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) -
- SIZEOF(xGenericReply));
-
- rep.backX = backX;
- rep.backY = backY;
-
- if (rep.numBackClipRects)
- rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
-
- if (rep.numClipRects)
- rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
-
- rep.length = ((rep.length + 3) & ~3) >> 2;
-
- WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
-
- if (rep.numClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numClipRects,
- (char *)pClipRects);
- }
-
- if (rep.numBackClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numBackClipRects,
- (char *)pBackClipRects);
- }
-
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIGetDeviceInfo(
- register ClientPtr client
-)
-{
- xXF86DRIGetDeviceInfoReply rep;
- drm_handle_t hFrameBuffer;
- void *pDevPrivate;
-
- REQUEST(xXF86DRIGetDeviceInfoReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen],
- &hFrameBuffer,
- (int*)&rep.framebufferOrigin,
- (int*)&rep.framebufferSize,
- (int*)&rep.framebufferStride,
- (int*)&rep.devPrivateSize,
- &pDevPrivate)) {
- return BadValue;
- }
-
- rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff);
-#if defined(LONG64) && !defined(__linux__)
- rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
-#else
- rep.hFrameBufferHigh = 0;
-#endif
-
- rep.length = 0;
- if (rep.devPrivateSize) {
- rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) -
- SIZEOF(xGenericReply) +
- ((rep.devPrivateSize + 3) & ~3)) >> 2;
- }
-
- WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
- if (rep.length) {
- WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
- }
- return (client->noClientException);
-}
-
-static int
-ProcXF86DRIDispatch (
- register ClientPtr client
-)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_XF86DRIQueryVersion:
- return ProcXF86DRIQueryVersion(client);
- case X_XF86DRIQueryDirectRenderingCapable:
- return ProcXF86DRIQueryDirectRenderingCapable(client);
- }
-
- if (!LocalClient(client))
- return DRIErrorBase + XF86DRIClientNotLocal;
-
- switch (stuff->data)
- {
- case X_XF86DRIOpenConnection:
- return ProcXF86DRIOpenConnection(client);
- case X_XF86DRICloseConnection:
- return ProcXF86DRICloseConnection(client);
- case X_XF86DRIGetClientDriverName:
- return ProcXF86DRIGetClientDriverName(client);
- case X_XF86DRICreateContext:
- return ProcXF86DRICreateContext(client);
- case X_XF86DRIDestroyContext:
- return ProcXF86DRIDestroyContext(client);
- case X_XF86DRICreateDrawable:
- return ProcXF86DRICreateDrawable(client);
- case X_XF86DRIDestroyDrawable:
- return ProcXF86DRIDestroyDrawable(client);
- case X_XF86DRIGetDrawableInfo:
- return ProcXF86DRIGetDrawableInfo(client);
- case X_XF86DRIGetDeviceInfo:
- return ProcXF86DRIGetDeviceInfo(client);
- case X_XF86DRIAuthConnection:
- return ProcXF86DRIAuthConnection(client);
- /* {Open,Close}FullScreen are deprecated now */
- default:
- return BadRequest;
- }
-}
-
-static int
-SProcXF86DRIQueryVersion(
- register ClientPtr client
-)
-{
- register int n;
- REQUEST(xXF86DRIQueryVersionReq);
- swaps(&stuff->length, n);
- return ProcXF86DRIQueryVersion(client);
-}
-
-static int
-SProcXF86DRIDispatch (
- register ClientPtr client
-)
-{
- REQUEST(xReq);
-
- /* It is bound to be non-local when there is byte swapping */
- if (!LocalClient(client))
- return DRIErrorBase + XF86DRIClientNotLocal;
-
- /* only local clients are allowed DRI access */
- switch (stuff->data)
- {
- case X_XF86DRIQueryVersion:
- return SProcXF86DRIQueryVersion(client);
- default:
- return BadRequest;
- }
-}
diff --git a/nx-X11/programs/Xserver/GL/windows/ChangeLog b/nx-X11/programs/Xserver/GL/windows/ChangeLog
deleted file mode 100644
index 43a817d6a..000000000
--- a/nx-X11/programs/Xserver/GL/windows/ChangeLog
+++ /dev/null
@@ -1,64 +0,0 @@
-2005-09-27 Ian Romanick <idr@us.ibm.com>
-
- * indirect.c:
- Remove __glEvalComputeK. It is no longer used.
-
-
-2005-04-09 Alexander Gottwald <ago at freedesktop dot org>
-
- * indirect.c:
- Fix passing of non-RGB visuals. The old code did not initialize the
- structure properly which lead to a crash in 8bpp mode
-
-2005-03-01 Alexander Gottwald <ago at freedesktop dot org>
-
- * indirect.c:
- * glwindows.h:
- If a context is already attached copy it instead of reattaching to keep
- displaylists and share displaylists
- Enable tracing of often called functions with GLWIN_ENABLE_TRACE
- ForceCurrent is a no-op now
-
-2005-02-02 Alexander Gottwald <ago at freedesktop dot org>
-
- * Imakefile:
- Bugzilla #1866 (https://bugs.freedesktop.org/show_bug.cgi?id=1866)
- attachment #1819 (https://bugs.freedesktop.org/attachment.cgi?id=1819):
- Define APIENTRY on windows to prevent <GL/gl.h> from loading <windows.h>
-
-2005-02-02 Alexander Gottwald <ago at freedesktop dot org>
-
- * glwrap.c:
- * glwindows.h:
- Bugzilla #1866 (https://bugs.freedesktop.org/show_bug.cgi?id=1866)
- attachment #1818 (https://bugs.freedesktop.org/attachment.cgi?id=1818):
- Include Xwindows.h before GL/gl.h to prevent loading windows.h which
- pollutes our namespace with some symbols.
-
-2005-01-27 Alexander Gottwald <ago at freedesktop dot org>
-
- * glwrap.c:
- Functions like glGenTextures and glBindTexture are in OpenGL 1.1
- and can be resolved at linktime.
-
-2004-11-15 Alexander Gottwald <ago at freedesktop dot org>
-
- * indirect.c:
- Bugzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802
- Added mingw (Win32) port
-
-2004-08-13 Alexander Gottwald <ago@freedesktop.org>
-
- * Imakefile: Added $(MESASRCDIR)/src/mesa/glapi to INCLUDES.
- Removed $(SERVERSRC)/mi from INCLUDES.
- Rearranged INCLUDES for better readability.
- * glwindows.h: Removed mipointrst.h and miscstruct.h from #include
- since they are not used anymore.
-
-2004-05-27 Alexander Gottwald <ago@freedesktop.org>
-
- * glwindows.h: write current function and line in debug output
- * indirect.c: moved actual setup and creation of windows GL context to
- glWinCreateContextReal.
- * indirect.c (glWinCreateContext): Deferred context creation to attach.
- * indirect.c (glWinMakeCurrent): Check if context is NULL. Fixes segfault.
diff --git a/nx-X11/programs/Xserver/GL/windows/Imakefile b/nx-X11/programs/Xserver/GL/windows/Imakefile
deleted file mode 100755
index 2b3ddeb12..000000000
--- a/nx-X11/programs/Xserver/GL/windows/Imakefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <Server.tmpl>
-
-LinkSourceFile(compsize.c,$(MESASRCDIR)/src/glx/x11)
-
- SRCS = compsize.c indirect.c glwrap.c
- OBJS = compsize.o indirect.o glwrap.o
-
- INCLUDES = -I. \
- -I$(INCLUDESRC) \
- -I$(XINCLUDESRC) \
- -I$(EXTINCSRC) \
- -I$(SERVERSRC)/include \
- -I$(SERVERSRC)/render \
- -I$(SERVERSRC)/hw/xwin \
- -I$(SERVERSRC)/GL/include \
- -I$(SERVERSRC)/GL/glx \
- -I$(LIBSRC)/GL/glx \
- -I$(LIBSRC)/GL/include \
- -I$(MESASRCDIR)/include \
- -I$(MESASRCDIR)/src \
- -I$(MESASRCDIR)/src/mesa/glapi \
- $(GL_INCLUDES)
-
-#if defined(GlxUseWindows) && GlxUseWindows
- CYGWIN_GL_DEFINES = -DUSE_OPENGL32
-#endif
-#if defined(Win32Architecture)
-# undef __stdcall
- APIENTRY_DEFS = -DAPIENTRY=__stdcall
-#endif
- DEFINES = $(GLX_DEFINES) $(CYGWIN_GL_DEFINES) $(APIENTRY_DEFS)
-
-NormalLibraryTarget(GLcore,$(OBJS))
-NormalLibraryObjectRule()
-
-DependTarget()
diff --git a/nx-X11/programs/Xserver/GL/windows/glwindows.h b/nx-X11/programs/Xserver/GL/windows/glwindows.h
deleted file mode 100644
index 74e81f24f..000000000
--- a/nx-X11/programs/Xserver/GL/windows/glwindows.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/Xwindows.h>
-#include <GL/gl.h>
-#include <GL/glext.h>
-
-#include <glxserver.h>
-#include <glxext.h>
-
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
-#include <glxutil.h>
-#include <glxscreens.h>
-#include <GL/internal/glcore.h>
-#include <stdlib.h>
-
-
-typedef struct {
- unsigned enableDebug : 1;
- unsigned enableTrace : 1;
- unsigned dumpPFD : 1;
- unsigned dumpHWND : 1;
- unsigned dumpDC : 1;
-} glWinDebugSettingsRec, *glWinDebugSettingsPtr;
-extern glWinDebugSettingsRec glWinDebugSettings;
-
-typedef struct {
- int num_vis;
- __GLcontextModes *modes;
- void **priv;
-
- /* wrapped screen functions */
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
- CopyWindowProcPtr CopyWindow;
-} glWinScreenRec;
-
-extern glWinScreenRec glWinScreens[MAXSCREENS];
-
-#define glWinGetScreenPriv(pScreen) &glWinScreens[pScreen->myNum]
-#define glWinScreenPriv(pScreen) glWinScreenRec *pScreenPriv = glWinGetScreenPriv(pScreen);
-
-#if 1
-#define GLWIN_TRACE() if (glWinDebugSettings.enableTrace) ErrorF("%s:%d: Trace\n", __FUNCTION__, __LINE__ )
-#define GLWIN_TRACE_MSG(msg, args...) if (glWinDebugSettings.enableTrace) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
-#define GLWIN_DEBUG_MSG(msg, args...) if (glWinDebugSettings.enableDebug) ErrorF("%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
-#define GLWIN_DEBUG_MSG2(msg, args...) if (glWinDebugSettings.enableDebug) ErrorF(msg, ##args )
-#else
-#define GLWIN_TRACE()
-#define GLWIN_TRACE_MSG(a, ...)
-#define GLWIN_DEBUG_MSG(a, ...)
-#define GLWIN_DEBUG_MSG2(a, ...)
-#endif
-
diff --git a/nx-X11/programs/Xserver/GL/windows/glwrap.c b/nx-X11/programs/Xserver/GL/windows/glwrap.c
deleted file mode 100755
index f0b38b228..000000000
--- a/nx-X11/programs/Xserver/GL/windows/glwrap.c
+++ /dev/null
@@ -1,583 +0,0 @@
-/*
- * GLX implementation that uses Win32's OpenGL
- * Wrapper functions for Win32's OpenGL
- *
- * Authors: Alexander Gottwald
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/Xwindows.h>
-#include <GL/gl.h>
-#include <GL/glext.h>
-#include <glxserver.h>
-#include <glxext.h>
-
-#define RESOLVE_RET(procname, symbol, retval) \
- static Bool init = TRUE; \
- static procname proc = NULL; \
- if (init) { \
- proc = (procname)wglGetProcAddress(symbol); \
- init = FALSE; \
- if (proc == NULL) { \
- ErrorF("glwrap: Can't resolve \"%s\"\n", symbol); \
- } else \
- ErrorF("glwrap: resolved \"%s\"\n", symbol); \
- } \
- if (proc == NULL) { \
- __glXErrorCallBack(NULL, 0); \
- return retval; \
- }
-#define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,)
-
-
-/*
- * GL_ARB_imaging
- */
-
-
-GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat,
- GLsizei width, GLenum format,
- GLenum type, const GLvoid *table )
-{
- RESOLVE(PFNGLCOLORTABLEPROC, "glColorTable");
- proc(target, internalformat, width, format, type, table);
-}
-
-GLAPI void GLAPIENTRY glColorSubTable( GLenum target,
- GLsizei start, GLsizei count,
- GLenum format, GLenum type,
- const GLvoid *data )
-{
- RESOLVE(PFNGLCOLORSUBTABLEPROC, "glColorSubTable");
- proc(target, start, count, format, type, data);
-}
-
-GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname,
- const GLint *params)
-{
- RESOLVE(PFNGLCOLORTABLEPARAMETERIVPROC, "glColorTableParameteriv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname,
- const GLfloat *params)
-{
- RESOLVE(PFNGLCOLORTABLEPARAMETERFVPROC, "glColorTableParameterfv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start,
- GLint x, GLint y, GLsizei width )
-{
- RESOLVE(PFNGLCOPYCOLORSUBTABLEPROC, "glCopyColorSubTable");
- proc(target, start, x, y, width);
-}
-
-GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat,
- GLint x, GLint y, GLsizei width )
-{
- RESOLVE(PFNGLCOPYCOLORTABLEPROC, "glCopyColorTable");
- proc(target, internalformat, x, y, width);
-}
-
-
-GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format,
- GLenum type, GLvoid *table )
-{
- RESOLVE(PFNGLGETCOLORTABLEPROC, "glGetColorTable");
- proc(target, format, type, table);
-}
-
-GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname,
- GLfloat *params )
-{
- RESOLVE(PFNGLGETCOLORTABLEPARAMETERFVPROC, "glGetColorTableParameterfv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname,
- GLint *params )
-{
- RESOLVE(PFNGLGETCOLORTABLEPARAMETERIVPROC, "glGetColorTableParameteriv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glBlendEquation( GLenum mode )
-{
- RESOLVE(PFNGLBLENDEQUATIONPROC, "glBlendEquation");
- proc(mode);
-}
-
-GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green,
- GLclampf blue, GLclampf alpha )
-{
- RESOLVE(PFNGLBLENDCOLORPROC, "glBlendColor");
- proc(red, green, blue, alpha);
-}
-
-GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width,
- GLenum internalformat, GLboolean sink )
-{
- RESOLVE(PFNGLHISTOGRAMPROC, "glHistogram");
- proc(target, width, internalformat, sink);
-}
-
-GLAPI void GLAPIENTRY glResetHistogram( GLenum target )
-{
- RESOLVE(PFNGLRESETHISTOGRAMPROC, "glResetHistogram");
- proc(target);
-}
-
-GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset,
- GLenum format, GLenum type,
- GLvoid *values )
-{
- RESOLVE(PFNGLGETHISTOGRAMPROC, "glGetHistogram");
- proc(target, reset, format, type, values);
-};
-
-GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname,
- GLfloat *params )
-{
- RESOLVE(PFNGLGETHISTOGRAMPARAMETERFVPROC, "glGetHistogramParameterfv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname,
- GLint *params )
-{
- RESOLVE(PFNGLGETHISTOGRAMPARAMETERIVPROC, "glGetHistogramParameteriv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat,
- GLboolean sink )
-{
- RESOLVE(PFNGLMINMAXPROC, "glMinmax");
- proc(target, internalformat, sink);
-}
-
-GLAPI void GLAPIENTRY glResetMinmax( GLenum target )
-{
- RESOLVE(PFNGLRESETMINMAXPROC, "glResetMinmax");
- proc(target);
-}
-
-GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset,
- GLenum format, GLenum types,
- GLvoid *values )
-{
- RESOLVE(PFNGLGETMINMAXPROC, "glGetMinmax");
- proc(target, reset, format, types, values);
-}
-
-GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname,
- GLfloat *params )
-{
- RESOLVE(PFNGLGETMINMAXPARAMETERFVPROC, "glGetMinmaxParameterfv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname,
- GLint *params )
-{
- RESOLVE(PFNGLGETMINMAXPARAMETERIVPROC, "glGetMinmaxParameteriv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target,
- GLenum internalformat, GLsizei width, GLenum format, GLenum type,
- const GLvoid *image )
-{
- RESOLVE(PFNGLCONVOLUTIONFILTER1DPROC, "glConvolutionFilter1D");
- proc(target, internalformat, width, format, type, image);
-}
-
-GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target,
- GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
- GLenum type, const GLvoid *image )
-{
- RESOLVE(PFNGLCONVOLUTIONFILTER2DPROC, "glConvolutionFilter2D");
- proc(target, internalformat, width, height, format, type, image);
-}
-
-GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname,
- GLfloat params )
-{
- RESOLVE(PFNGLCONVOLUTIONPARAMETERFPROC, "glConvolutionParameterf");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname,
- const GLfloat *params )
-{
- RESOLVE(PFNGLCONVOLUTIONPARAMETERFVPROC, "glConvolutionParameterfv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname,
- GLint params )
-{
- RESOLVE(PFNGLCONVOLUTIONPARAMETERIPROC, "glConvolutionParameteri");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname,
- const GLint *params )
-{
- RESOLVE(PFNGLCONVOLUTIONPARAMETERIVPROC, "glConvolutionParameteriv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target,
- GLenum internalformat, GLint x, GLint y, GLsizei width )
-{
- RESOLVE(PFNGLCOPYCONVOLUTIONFILTER1DPROC, "glCopyConvolutionFilter1D");
- proc(target, internalformat, x, y, width);
-}
-
-GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target,
- GLenum internalformat, GLint x, GLint y, GLsizei width,
- GLsizei height)
-{
- RESOLVE(PFNGLCOPYCONVOLUTIONFILTER2DPROC, "glCopyConvolutionFilter2D");
- proc(target, internalformat, x, y, width, height);
-}
-
-GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format,
- GLenum type, GLvoid *image )
-{
- RESOLVE(PFNGLGETCONVOLUTIONFILTERPROC, "glGetConvolutionFilter");
- proc(target, format, type, image);
-}
-
-GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname,
- GLfloat *params )
-{
- RESOLVE(PFNGLGETCONVOLUTIONPARAMETERFVPROC, "glGetConvolutionParameterfv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname,
- GLint *params )
-{
- RESOLVE(PFNGLGETCONVOLUTIONPARAMETERIVPROC, "glGetConvolutionParameteriv");
- proc(target, pname, params);
-}
-
-GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
- GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
- GLenum type, const GLvoid *row, const GLvoid *column )
-{
- RESOLVE(PFNGLSEPARABLEFILTER2DPROC, "glSeparableFilter2D");
- proc(target, internalformat, width, height, format, type, row, column);
-}
-
-GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
- GLenum type, GLvoid *row, GLvoid *column, GLvoid *span )
-{
- RESOLVE(PFNGLGETSEPARABLEFILTERPROC, "glGetSeparableFilter");
- proc(target, format, type, row, column, span);
-}
-
-/*
- * OpenGL 1.2
- */
-
-GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level,
- GLint internalFormat,
- GLsizei width, GLsizei height,
- GLsizei depth, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- RESOLVE(PFNGLTEXIMAGE3DPROC, "glTexImage3D");
- proc(target, level, internalFormat, width, height, depth, border, format, type, pixels);
-}
-
-GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint zoffset, GLsizei width,
- GLsizei height, GLsizei depth,
- GLenum format,
- GLenum type, const GLvoid *pixels)
-{
- RESOLVE(PFNGLTEXSUBIMAGE3DPROC, "glTexSubImage3D");
- proc(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
-}
-
-GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint zoffset, GLint x,
- GLint y, GLsizei width,
- GLsizei height )
-{
- RESOLVE(PFNGLCOPYTEXSUBIMAGE3DPROC, "glCopyTexSubImage3D");
- proc(target, level, xoffset, yoffset, zoffset, x, y, width, height);
-}
-
-
-/*
- * 20. GL_EXT_texture_object
- */
-GLAPI void GLAPIENTRY glGenTexturesEXT( GLsizei n, GLuint *textures )
-{
- glGenTextures(n, textures);
-}
-
-GLAPI void GLAPIENTRY glDeleteTexturesEXT( GLsizei n, const GLuint *textures)
-{
- glDeleteTextures(n, textures);
-}
-
-GLAPI void GLAPIENTRY glBindTextureEXT( GLenum target, GLuint texture )
-{
- glBindTexture(target, target);
-}
-
-GLAPI void GLAPIENTRY glPrioritizeTexturesEXT( GLsizei n, const GLuint *textures, const GLclampf *priorities )
-{
- glPrioritizeTextures(n, textures, priorities);
-}
-
-GLAPI GLboolean GLAPIENTRY glAreTexturesResidentEXT( GLsizei n, const GLuint *textures, GLboolean *residences )
-{
- return glAreTexturesResident(n, textures, residences);
-}
-
-GLAPI GLboolean GLAPIENTRY glIsTextureEXT( GLuint texture )
-{
- return glIsTexture(texture);
-}
-
-/*
- * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
- */
-
-GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture)
-{
- RESOLVE(PFNGLACTIVETEXTUREARBPROC, "glActiveTextureARB");
- proc(texture);
-}
-
-GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD1DVARBPROC, "glMultiTexCoord1dvARB");
- proc(target, v);
-}
-
-GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD1FVARBPROC, "glMultiTexCoord1fvARB");
- proc(target, v);
-}
-
-GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD1IVARBPROC, "glMultiTexCoord1ivARB");
- proc(target, v);
-}
-
-GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD2DVARBPROC, "glMultiTexCoord2dvARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD2FVARBPROC, "glMultiTexCoord2fvARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD2IVARBPROC, "glMultiTexCoord2ivARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD3DVARBPROC, "glMultiTexCoord3dvARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD3FVARBPROC, "glMultiTexCoord3fvARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD3IVARBPROC, "glMultiTexCoord3ivARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD4DVARBPROC, "glMultiTexCoord4dvARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD4FVARBPROC, "glMultiTexCoord4fvARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD4IVARBPROC, "glMultiTexCoord4ivARB");
- proc(target, v);
-}
-GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v)
-{
- RESOLVE(PFNGLMULTITEXCOORD1SVARBPROC, "glMultiTexCoord1svARB");
- proc(target, v);
-}
-
-
-GLAPI void GLAPIENTRY glActiveStencilFaceEXT(GLenum face)
-{
- RESOLVE(PFNGLACTIVESTENCILFACEEXTPROC, "glActiveStencilFaceEXT");
- proc(face);
-}
-
-GLAPI void APIENTRY glPointParameterfARB(GLenum pname, GLfloat param)
-{
- RESOLVE(PFNGLPOINTPARAMETERFARBPROC, "glPointParameterfARB");
- proc(pname, param);
-}
-
-GLAPI void APIENTRY glPointParameterfvARB(GLenum pname, const GLfloat *params)
-{
- RESOLVE(PFNGLPOINTPARAMETERFVARBPROC, "glPointParameterfvARB");
- proc(pname, params);
-}
-
-
-GLAPI void APIENTRY glWindowPos3fARB(GLfloat x, GLfloat y, GLfloat z)
-{
- RESOLVE(PFNGLWINDOWPOS3FARBPROC, "glWindowPos3fARB");
- proc(x, y, z);
-}
-
-GLAPI void APIENTRY glPointParameteri(GLenum pname, GLint param)
-{
- RESOLVE(PFNGLPOINTPARAMETERIPROC, "glPointParameteri");
- proc(pname, param);
-}
-
-GLAPI void APIENTRY glPointParameteriv(GLenum pname, const GLint *params)
-{
- RESOLVE(PFNGLPOINTPARAMETERIVPROC, "glPointParameteriv");
- proc(pname, params);
-}
-
-GLAPI void APIENTRY glPointParameteriNV(GLenum pname, GLint param)
-{
- RESOLVE(PFNGLPOINTPARAMETERINVPROC, "glPointParameteriNV");
- proc(pname, param);
-}
-
-GLAPI void APIENTRY glPointParameterivNV(GLenum pname, const GLint *params)
-{
- RESOLVE(PFNGLPOINTPARAMETERIVNVPROC, "glPointParameterivNV");
- proc(pname, params);
-}
-
-GLAPI void APIENTRY glSecondaryColor3bv(const GLbyte *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3BVPROC, "glSecondaryColor3bv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColor3dv(const GLdouble *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3DVPROC, "glSecondaryColor3dv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColor3fv(const GLfloat *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3FVPROC, "glSecondaryColor3fv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColor3iv(const GLint *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3IVPROC, "glSecondaryColor3iv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColor3sv(const GLshort *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3SVPROC, "glSecondaryColor3sv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColor3ubv(const GLubyte *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3UBVPROC, "glSecondaryColor3ubv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColor3uiv(const GLuint *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3UIVPROC, "glSecondaryColor3uiv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColor3usv(const GLushort *v)
-{
- RESOLVE(PFNGLSECONDARYCOLOR3USVPROC, "glSecondaryColor3usv");
- proc(v);
-}
-GLAPI void APIENTRY glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
-{
- RESOLVE(PFNGLSECONDARYCOLORPOINTERPROC, "glSecondaryColorPointer");
- proc(size, type, stride, pointer);
-}
-
-
-GLAPI void APIENTRY glBlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
-{
- RESOLVE(PFNGLBLENDFUNCSEPARATEPROC, "glBlendFuncSeparate");
- proc(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
-}
-GLAPI void APIENTRY glFogCoordfv(const GLfloat *coord)
-{
- RESOLVE(PFNGLFOGCOORDFVPROC, "glFogCoordfv");
- proc(coord);
-}
-GLAPI void APIENTRY glFogCoorddv(const GLdouble *coord)
-{
- RESOLVE(PFNGLFOGCOORDDVPROC, "glFogCoorddv");
- proc(coord);
-}
-GLAPI void APIENTRY glFogCoordPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
-{
- RESOLVE(PFNGLFOGCOORDPOINTERPROC, "glFogCoordPointer");
- proc(type, stride, pointer);
-}
-
-
-GLAPI void APIENTRY glSampleCoverageARB(GLclampf value, GLboolean invert)
-{
- RESOLVE(PFNGLSAMPLECOVERAGEARBPROC, "glSampleCoverageARB");
- proc(value, invert);
-}
-GLAPI void APIENTRY glSampleMaskSGIS(GLclampf value, GLboolean invert)
-{
- RESOLVE(PFNGLSAMPLEMASKSGISPROC, "glSampleMaskSGIS");
- proc(value, invert);
-}
-GLAPI void APIENTRY glSamplePatternSGIS(GLenum pattern)
-{
- RESOLVE(PFNGLSAMPLEPATTERNSGISPROC, "glSamplePatternSGIS");
- proc(pattern);
-}
diff --git a/nx-X11/programs/Xserver/GL/windows/indirect.c b/nx-X11/programs/Xserver/GL/windows/indirect.c
deleted file mode 100755
index 5e12022f4..000000000
--- a/nx-X11/programs/Xserver/GL/windows/indirect.c
+++ /dev/null
@@ -1,1605 +0,0 @@
-/*
- * GLX implementation that uses Windows OpenGL library
- * (Indirect rendering path)
- *
- * Authors: Alexander Gottwald
- */
-/*
- * Portions of this file are copied from GL/apple/indirect.c,
- * which contains the following copyright:
- *
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- * Copyright (c) 2002 Apple Computer, Inc.
- *
- * Portions of this file are copied from xf86glx.c,
- * which contains the following copyright:
- *
- * 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, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) 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.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "glwindows.h"
-#include <glcontextmodes.h>
-#include <stdint.h>
-
-#include <winpriv.h>
-
-#define GLWIN_DEBUG_HWND(hwnd) \
- if (glWinDebugSettings.dumpHWND) { \
- char buffer[1024]; \
- if (GetWindowText(hwnd, buffer, sizeof(buffer))==0) *buffer=0; \
- GLWIN_DEBUG_MSG("Got HWND %s (%p)\n", buffer, hwnd); \
- }
-
-
-/* ggs: needed to call back to glx with visual configs */
-extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs, void **configprivs);
-
-glWinDebugSettingsRec glWinDebugSettings = { 1, 0, 0, 0, 0};
-
-static void glWinInitDebugSettings(void)
-{
- char *envptr;
-
- envptr = getenv("GLWIN_ENABLE_DEBUG");
- if (envptr != NULL)
- glWinDebugSettings.enableDebug = (atoi(envptr) == 1);
-
- envptr = getenv("GLWIN_ENABLE_TRACE");
- if (envptr != NULL)
- glWinDebugSettings.enableTrace = (atoi(envptr) == 1);
-
- envptr = getenv("GLWIN_DUMP_PFD");
- if (envptr != NULL)
- glWinDebugSettings.dumpPFD = (atoi(envptr) == 1);
-
- envptr = getenv("GLWIN_DUMP_HWND");
- if (envptr != NULL)
- glWinDebugSettings.dumpHWND = (atoi(envptr) == 1);
-
- envptr = getenv("GLWIN_DUMP_DC");
- if (envptr != NULL)
- glWinDebugSettings.dumpDC = (atoi(envptr) == 1);
-}
-
-static char errorbuffer[1024];
-const char *glWinErrorMessage(void)
-{
- if (!FormatMessage(
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &errorbuffer,
- sizeof(errorbuffer),
- NULL ))
- {
- snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error in FormatMessage: %08x!\n", (unsigned)GetLastError());
- }
- return errorbuffer;
-}
-
-/*
- * GLX implementation that uses Win32's OpenGL
- */
-
-/*
- * 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;
-}
-
-/* some prototypes */
-static Bool glWinScreenProbe(int screen);
-static Bool glWinInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB);
-static void glWinSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates);
-static __GLinterface *glWinCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC);
-static void glWinCreateBuffer(__GLXdrawablePrivate *glxPriv);
-static void glWinResetExtension(void);
-
-/*
- * 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 = {
- glWinScreenProbe, /* Must be generic and handle all screens */
- glWinCreateContext, /* Substitute screen's createContext routine */
- glWinCreateBuffer, /* Substitute screen's createBuffer routine */
- NULL, /* Set up pGlxVisual in probe */
- NULL, /* Set up pVisualPriv in probe */
- 0, /* Set up numVisuals in probe */
- 0, /* Set up numUsableVisuals in probe */
- "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 */
-};
-
-void *__glXglDDXScreenInfo(void) {
- return &__glDDXScreenInfo;
-}
-
-static __GLXextensionInfo __glDDXExtensionInfo = {
- GL_CORE_WINDOWS,
- glWinResetExtension,
- glWinInitVisuals,
- glWinSetVisualConfigs
-};
-
-void *__glXglDDXExtensionInfo(void) {
- return &__glDDXExtensionInfo;
-}
-
-/* prototypes */
-
-static GLboolean glWinDestroyContext(__GLcontext *gc);
-static GLboolean glWinLoseCurrent(__GLcontext *gc);
-static GLboolean glWinMakeCurrent(__GLcontext *gc);
-static GLboolean glWinShareContext(__GLcontext *gc, __GLcontext *gcShare);
-static GLboolean glWinCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask);
-static GLboolean glWinForceCurrent(__GLcontext *gc);
-
-/* Drawing surface notification callbacks */
-static GLboolean glWinNotifyResize(__GLcontext *gc);
-static void glWinNotifyDestroy(__GLcontext *gc);
-static void glWinNotifySwapBuffers(__GLcontext *gc);
-
-/* Dispatch table override control for external agents like libGLS */
-static struct __GLdispatchStateRec* glWinDispatchExec(__GLcontext *gc);
-static void glWinBeginDispatchOverride(__GLcontext *gc);
-static void glWinEndDispatchOverride(__GLcontext *gc);
-
-/* Debug output */
-static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd);
-
-static __GLexports glWinExports = {
- glWinDestroyContext,
- glWinLoseCurrent,
- glWinMakeCurrent,
- glWinShareContext,
- glWinCopyContext,
- glWinForceCurrent,
-
- glWinNotifyResize,
- glWinNotifyDestroy,
- glWinNotifySwapBuffers,
-
- glWinDispatchExec,
- glWinBeginDispatchOverride,
- glWinEndDispatchOverride
-};
-
-glWinScreenRec glWinScreens[MAXSCREENS];
-
-/* __GLdrawablePrivate->private */
-typedef struct {
- DrawablePtr pDraw;
- /* xp_surface_id sid; */
-} GLWinDrawableRec;
-
-struct __GLcontextRec {
- struct __GLinterfaceRec interface; /* required to be first */
-
- HGLRC ctx; /* Windows GL Context */
-
- HDC dc; /* Windows Device Context */
- winWindowInfoRec winInfo; /* Window info from XWin */
-
- PIXELFORMATDESCRIPTOR pfd; /* Pixelformat flags */
- int pixelFormat; /* Pixelformat index */
-
- unsigned isAttached :1; /* Flag to track if context is attached */
-};
-
-static HDC glWinMakeDC(__GLcontext *gc)
-{
- HDC dc;
-
- /*if (gc->winInfo.hrgn == NULL)
- {
- GLWIN_DEBUG_MSG("Creating region from RECT(%ld,%ld,%ld,%ld):",
- gc->winInfo.rect.left,
- gc->winInfo.rect.top,
- gc->winInfo.rect.right,
- gc->winInfo.rect.bottom);
- gc->winInfo.hrgn = CreateRectRgnIndirect(&gc->winInfo.rect);
- GLWIN_DEBUG_MSG2("%p\n", gc->winInfo.hrgn);
- }*/
-
- if (glWinDebugSettings.enableTrace)
- GLWIN_DEBUG_HWND(gc->winInfo.hwnd);
-
- dc = GetDC(gc->winInfo.hwnd);
- /*dc = GetDCEx(gc->winInfo.hwnd, gc->winInfo.hrgn,
- DCX_WINDOW | DCX_NORESETATTRS ); */
-
- if (dc == NULL)
- ErrorF("GetDC error: %s\n", glWinErrorMessage());
- return dc;
-}
-
-static void unattach(__GLcontext *gc)
-{
- BOOL ret;
- GLWIN_DEBUG_MSG("unattach (ctx %p)\n", gc->ctx);
- if (!gc->isAttached)
- {
- ErrorF("called unattach on an unattached context\n");
- return;
- }
-
- if (gc->ctx)
- {
- ret = wglDeleteContext(gc->ctx);
- if (!ret)
- ErrorF("wglDeleteContext error: %s\n", glWinErrorMessage());
- gc->ctx = NULL;
- }
-
- if (gc->winInfo.hrgn)
- {
- ret = DeleteObject(gc->winInfo.hrgn);
- if (!ret)
- ErrorF("DeleteObject error: %s\n", glWinErrorMessage());
- gc->winInfo.hrgn = NULL;
- }
-
- gc->isAttached = 0;
-}
-
-static BOOL glWinAdjustHWND(__GLcontext *gc, WindowPtr pWin)
-{
- HDC dc;
- BOOL ret;
- HGLRC newctx;
- HWND oldhwnd;
-
- GLWIN_DEBUG_MSG("glWinAdjustHWND (ctx %p, pWin %p)\n", gc->ctx, pWin);
-
- if (pWin == NULL)
- {
- GLWIN_DEBUG_MSG("Deferring until window is created\n");
- return FALSE;
- }
-
- oldhwnd = gc->winInfo.hwnd;
- winGetWindowInfo(pWin, &gc->winInfo);
-
- GLWIN_DEBUG_HWND(gc->winInfo.hwnd);
- if (gc->winInfo.hwnd == NULL)
- {
- GLWIN_DEBUG_MSG("Deferring until window is created\n");
- return FALSE;
- }
-
- dc = glWinMakeDC(gc);
-
- if (glWinDebugSettings.dumpDC)
- GLWIN_DEBUG_MSG("Got HDC %p\n", dc);
-
- gc->pixelFormat = ChoosePixelFormat(dc, &gc->pfd);
- if (gc->pixelFormat == 0)
- {
- ErrorF("ChoosePixelFormat error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- ret = SetPixelFormat(dc, gc->pixelFormat, &gc->pfd);
- if (!ret) {
- ErrorF("SetPixelFormat error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- newctx = wglCreateContext(dc);
- if (newctx == NULL) {
- ErrorF("wglCreateContext error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- GLWIN_DEBUG_MSG("wglCreateContext (ctx %p)\n", newctx);
-
- if (!wglShareLists(gc->ctx, newctx))
- {
- ErrorF("wglShareLists error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- if (oldhwnd != gc->winInfo.hwnd)
- {
- GLWIN_DEBUG_MSG("Trying wglCopyContext\n");
- if (!wglCopyContext(gc->ctx, newctx, GL_ALL_ATTRIB_BITS))
- {
- ErrorF("wglCopyContext error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
- }
-
- if (!wglDeleteContext(gc->ctx))
- {
- ErrorF("wglDeleteContext error: %s\n", glWinErrorMessage());
- }
-
- gc->ctx = newctx;
-
- if (!wglMakeCurrent(dc, gc->ctx)) {
- ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- ReleaseDC(gc->winInfo.hwnd, dc);
-
- return TRUE;
-}
-
-static BOOL glWinCreateContextReal(__GLcontext *gc, WindowPtr pWin)
-{
- HDC dc;
- BOOL ret;
-
- GLWIN_DEBUG_MSG("glWinCreateContextReal (pWin %p)\n", pWin);
-
- if (pWin == NULL)
- {
- GLWIN_DEBUG_MSG("Deferring until window is created\n");
- return FALSE;
- }
-
- winGetWindowInfo(pWin, &gc->winInfo);
-
- GLWIN_DEBUG_HWND(gc->winInfo.hwnd);
- if (gc->winInfo.hwnd == NULL)
- {
- GLWIN_DEBUG_MSG("Deferring until window is created\n");
- return FALSE;
- }
-
-
- dc = glWinMakeDC(gc);
-
- if (glWinDebugSettings.dumpDC)
- GLWIN_DEBUG_MSG("Got HDC %p\n", dc);
-
- gc->pixelFormat = ChoosePixelFormat(dc, &gc->pfd);
- if (gc->pixelFormat == 0)
- {
- ErrorF("ChoosePixelFormat error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- ret = SetPixelFormat(dc, gc->pixelFormat, &gc->pfd);
- if (!ret) {
- ErrorF("SetPixelFormat error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- gc->ctx = wglCreateContext(dc);
- if (gc->ctx == NULL) {
- ErrorF("wglCreateContext error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- GLWIN_DEBUG_MSG("glWinCreateContextReal (ctx %p)\n", gc->ctx);
-
- if (!wglMakeCurrent(dc, gc->ctx)) {
- ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
- return FALSE;
- }
-
- ReleaseDC(gc->winInfo.hwnd, dc);
-
- return TRUE;
-}
-
-static void attach(__GLcontext *gc, __GLdrawablePrivate *glPriv)
-{
- __GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
-
- GLWIN_DEBUG_MSG("attach (ctx %p)\n", gc->ctx);
-
- if (gc->isAttached)
- {
- ErrorF("called attach on an attached context\n");
- return;
- }
-
- if (glxPriv->type == DRAWABLE_WINDOW)
- {
- WindowPtr pWin = (WindowPtr) glxPriv->pDraw;
- if (pWin == NULL)
- {
- GLWIN_DEBUG_MSG("Deferring ChoosePixelFormat until window is created\n");
- } else
- {
- if (glWinCreateContextReal(gc, pWin))
- {
- gc->isAttached = TRUE;
- GLWIN_DEBUG_MSG("attached\n");
- }
- }
- }
-}
-
-static GLboolean glWinLoseCurrent(__GLcontext *gc)
-{
- GLWIN_TRACE_MSG("glWinLoseCurrent (ctx %p)\n", gc->ctx);
-
- __glXLastContext = NULL; /* Mesa does this; why? */
-
- return GL_TRUE;
-}
-
-/* Context manipulation; return GL_FALSE on failure */
-static GLboolean glWinDestroyContext(__GLcontext *gc)
-{
- GLWIN_DEBUG_MSG("glWinDestroyContext (ctx %p)\n", gc->ctx);
-
- if (gc != NULL)
- {
- if (gc->isAttached)
- unattach(gc);
- if (gc->dc != NULL)
- DeleteDC(gc->dc);
- free(gc);
- }
-
- return GL_TRUE;
-}
-
-static GLboolean glWinMakeCurrent(__GLcontext *gc)
-{
- __GLdrawablePrivate *glPriv = gc->interface.imports.getDrawablePrivate(gc);
- BOOL ret;
- HDC dc;
-
- GLWIN_TRACE_MSG(" (ctx %p)\n", gc->ctx);
-
- if (!gc->isAttached)
- attach(gc, glPriv);
-
- if (gc->ctx == NULL) {
- ErrorF("Context is NULL\n");
- return GL_FALSE;
- }
-
- dc = glWinMakeDC(gc);
- ret = wglMakeCurrent(dc, gc->ctx);
- if (!ret)
- ErrorF("glMakeCurrent error: %s\n", glWinErrorMessage());
- ReleaseDC(gc->winInfo.hwnd, dc);
-
- return ret?GL_TRUE:GL_FALSE;
-}
-
-static GLboolean glWinShareContext(__GLcontext *gc, __GLcontext *gcShare)
-{
- GLWIN_DEBUG_MSG("glWinShareContext unimplemented\n");
-
- return GL_TRUE;
-}
-
-static GLboolean glWinCopyContext(__GLcontext *dst, const __GLcontext *src,
- GLuint mask)
-{
- BOOL ret;
-
- GLWIN_DEBUG_MSG("glWinCopyContext\n");
-
- ret = wglCopyContext(src->ctx, dst->ctx, mask);
- if (!ret)
- {
- ErrorF("wglCopyContext error: %s\n", glWinErrorMessage());
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-static GLboolean glWinForceCurrent(__GLcontext *gc)
-{
- GLWIN_TRACE_MSG(" (ctx %p)\n", gc->ctx);
-
- return GL_TRUE;
-}
-
-/* Drawing surface notification callbacks */
-
-static GLboolean glWinNotifyResize(__GLcontext *gc)
-{
- GLWIN_DEBUG_MSG("unimplemented glWinNotifyResize");
- return GL_TRUE;
-}
-
-static void glWinNotifyDestroy(__GLcontext *gc)
-{
- GLWIN_DEBUG_MSG("unimplemented glWinNotifyDestroy");
-}
-
-static void glWinNotifySwapBuffers(__GLcontext *gc)
-{
- GLWIN_DEBUG_MSG("unimplemented glWinNotifySwapBuffers");
-}
-
-/* Dispatch table override control for external agents like libGLS */
-static struct __GLdispatchStateRec* glWinDispatchExec(__GLcontext *gc)
-{
- GLWIN_DEBUG_MSG("unimplemented glWinDispatchExec");
- return NULL;
-}
-
-static void glWinBeginDispatchOverride(__GLcontext *gc)
-{
- GLWIN_DEBUG_MSG("unimplemented glWinBeginDispatchOverride");
-}
-
-static void glWinEndDispatchOverride(__GLcontext *gc)
-{
- GLWIN_DEBUG_MSG("unimplemented glWinEndDispatchOverride");
-}
-
-#define DUMP_PFD_FLAG(flag) \
- if (pfd->dwFlags & flag) { \
- ErrorF("%s%s", pipesym, #flag); \
- pipesym = " | "; \
- }
-
-static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd)
-{
- const char *pipesym = ""; /* will be set after first flag dump */
- ErrorF("PIXELFORMATDESCRIPTOR:\n");
- ErrorF("nSize = %u\n", pfd->nSize);
- ErrorF("nVersion = %u\n", pfd->nVersion);
- ErrorF("dwFlags = %lu = {", pfd->dwFlags);
- DUMP_PFD_FLAG(PFD_MAIN_PLANE);
- DUMP_PFD_FLAG(PFD_OVERLAY_PLANE);
- DUMP_PFD_FLAG(PFD_UNDERLAY_PLANE);
- DUMP_PFD_FLAG(PFD_DOUBLEBUFFER);
- DUMP_PFD_FLAG(PFD_STEREO);
- DUMP_PFD_FLAG(PFD_DRAW_TO_WINDOW);
- DUMP_PFD_FLAG(PFD_DRAW_TO_BITMAP);
- DUMP_PFD_FLAG(PFD_SUPPORT_GDI);
- DUMP_PFD_FLAG(PFD_SUPPORT_OPENGL);
- DUMP_PFD_FLAG(PFD_GENERIC_FORMAT);
- DUMP_PFD_FLAG(PFD_NEED_PALETTE);
- DUMP_PFD_FLAG(PFD_NEED_SYSTEM_PALETTE);
- DUMP_PFD_FLAG(PFD_SWAP_EXCHANGE);
- DUMP_PFD_FLAG(PFD_SWAP_COPY);
- DUMP_PFD_FLAG(PFD_SWAP_LAYER_BUFFERS);
- DUMP_PFD_FLAG(PFD_GENERIC_ACCELERATED);
- DUMP_PFD_FLAG(PFD_DEPTH_DONTCARE);
- DUMP_PFD_FLAG(PFD_DOUBLEBUFFER_DONTCARE);
- DUMP_PFD_FLAG(PFD_STEREO_DONTCARE);
- ErrorF("}\n");
-
- ErrorF("iPixelType = %hu = %s\n", pfd->iPixelType,
- (pfd->iPixelType == PFD_TYPE_RGBA ? "PFD_TYPE_RGBA" : "PFD_TYPE_COLORINDEX"));
- ErrorF("cColorBits = %hhu\n", pfd->cColorBits);
- ErrorF("cRedBits = %hhu\n", pfd->cRedBits);
- ErrorF("cRedShift = %hhu\n", pfd->cRedShift);
- ErrorF("cGreenBits = %hhu\n", pfd->cGreenBits);
- ErrorF("cGreenShift = %hhu\n", pfd->cGreenShift);
- ErrorF("cBlueBits = %hhu\n", pfd->cBlueBits);
- ErrorF("cBlueShift = %hhu\n", pfd->cBlueShift);
- ErrorF("cAlphaBits = %hhu\n", pfd->cAlphaBits);
- ErrorF("cAlphaShift = %hhu\n", pfd->cAlphaShift);
- ErrorF("cAccumBits = %hhu\n", pfd->cAccumBits);
- ErrorF("cAccumRedBits = %hhu\n", pfd->cAccumRedBits);
- ErrorF("cAccumGreenBits = %hhu\n", pfd->cAccumGreenBits);
- ErrorF("cAccumBlueBits = %hhu\n", pfd->cAccumBlueBits);
- ErrorF("cAccumAlphaBits = %hhu\n", pfd->cAccumAlphaBits);
- ErrorF("cDepthBits = %hhu\n", pfd->cDepthBits);
- ErrorF("cStencilBits = %hhu\n", pfd->cStencilBits);
- ErrorF("cAuxBuffers = %hhu\n", pfd->cAuxBuffers);
- ErrorF("iLayerType = %hhu\n", pfd->iLayerType);
- ErrorF("bReserved = %hhu\n", pfd->bReserved);
- ErrorF("dwLayerMask = %lu\n", pfd->dwLayerMask);
- ErrorF("dwVisibleMask = %lu\n", pfd->dwVisibleMask);
- ErrorF("dwDamageMask = %lu\n", pfd->dwDamageMask);
- ErrorF("\n");
-}
-
-static int makeFormat(__GLcontextModes *mode, PIXELFORMATDESCRIPTOR *pfdret)
-{
- PIXELFORMATDESCRIPTOR pfd = {
- sizeof(PIXELFORMATDESCRIPTOR), /* size of this pfd */
- 1, /* version number */
- PFD_DRAW_TO_WINDOW | /* support window */
- PFD_SUPPORT_OPENGL, /* support OpenGL */
- PFD_TYPE_RGBA, /* RGBA type */
- 24, /* 24-bit color depth */
- 0, 0, 0, 0, 0, 0, /* color bits ignored */
- 0, /* no alpha buffer */
- 0, /* shift bit ignored */
- 0, /* no accumulation buffer */
- 0, 0, 0, 0, /* accum bits ignored */
- 0, /* 32-bit z-buffer */
- 0, /* no stencil buffer */
- 0, /* no auxiliary buffer */
- PFD_MAIN_PLANE, /* main layer */
- 0, /* reserved */
- 0, 0, 0 /* layer masks ignored */
- }, *result = &pfd;
-
- /* disable anything but rgba. must get rgba to work first */
- if (!mode->rgbMode)
- return -1;
-
- if (mode->stereoMode) {
- result->dwFlags |= PFD_STEREO;
- }
- if (mode->doubleBufferMode) {
- result->dwFlags |= PFD_DOUBLEBUFFER;
- }
-
- if (mode->colorIndexMode) {
- /* ignored, see above */
- result->iPixelType = PFD_TYPE_COLORINDEX;
- result->cColorBits = mode->redBits + mode->greenBits + mode->blueBits;
- result->cRedBits = mode->redBits;
- result->cRedShift = 0; /* FIXME */
- result->cGreenBits = mode->greenBits;
- result->cGreenShift = 0; /* FIXME */
- result->cBlueBits = mode->blueBits;
- result->cBlueShift = 0; /* FIXME */
- result->cAlphaBits = mode->alphaBits;
- result->cAlphaShift = 0; /* FIXME */
- }
-
- if (mode->rgbMode) {
- result->iPixelType = PFD_TYPE_RGBA;
- result->cColorBits = mode->redBits + mode->greenBits + mode->blueBits;
- result->cRedBits = mode->redBits;
- result->cRedShift = 0; /* FIXME */
- result->cGreenBits = mode->greenBits;
- result->cGreenShift = 0; /* FIXME */
- result->cBlueBits = mode->blueBits;
- result->cBlueShift = 0; /* FIXME */
- result->cAlphaBits = mode->alphaBits;
- result->cAlphaShift = 0; /* FIXME */
- }
-
- if (mode->haveAccumBuffer) {
- result->cAccumBits = mode->accumRedBits + mode->accumGreenBits
- + mode->accumBlueBits + mode->accumAlphaBits;
- result->cAccumRedBits = mode->accumRedBits;
- result->cAccumGreenBits = mode->accumGreenBits;
- result->cAccumBlueBits = mode->accumBlueBits;
- result->cAccumAlphaBits = mode->accumAlphaBits;
- }
-
- if (mode->haveDepthBuffer) {
- result->cDepthBits = mode->depthBits;
- }
- if (mode->haveStencilBuffer) {
- result->cStencilBits = mode->stencilBits;
- }
-
- /* result->cAuxBuffers = mode->numAuxBuffers; */
-
- /* mode->level ignored */
-
- /* mode->pixmapMode ? */
-
- *pfdret = pfd;
-
- return 0;
-}
-
-static __GLinterface *glWinCreateContext(__GLimports *imports,
- __GLcontextModes *mode,
- __GLinterface *shareGC)
-{
- __GLcontext *result;
-
- GLWIN_DEBUG_MSG("glWinCreateContext\n");
-
- result = (__GLcontext *)calloc(1, sizeof(__GLcontext));
- if (!result)
- return NULL;
-
- result->interface.imports = *imports;
- result->interface.exports = glWinExports;
-
- if (makeFormat(mode, &result->pfd))
- {
- ErrorF("makeFormat failed\n");
- free(result);
- return NULL;
- }
-
- if (glWinDebugSettings.dumpPFD)
- pfdOut(&result->pfd);
-
- GLWIN_DEBUG_MSG("glWinCreateContext done\n");
- return (__GLinterface *)result;
-}
-
-Bool
-glWinRealizeWindow(WindowPtr pWin)
-{
- /* If this window has GL contexts, tell them to reattach */
- /* reattaching is bad: display lists and parameters get lost */
- Bool result;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum];
- __GLXdrawablePrivate *glxPriv;
-
- GLWIN_DEBUG_MSG("glWinRealizeWindow\n");
-
- /* Allow the window to be created (RootlessRealizeWindow is inside our wrap) */
- pScreen->RealizeWindow = screenPriv->RealizeWindow;
- result = pScreen->RealizeWindow(pWin);
- pScreen->RealizeWindow = glWinRealizeWindow;
-
- /* Re-attach this window's GL contexts, if any. */
- glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
- if (glxPriv) {
- __GLXcontext *gx;
- __GLcontext *gc;
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
- GLWIN_DEBUG_MSG("glWinRealizeWindow is GL drawable!\n");
-
- /* GL contexts bound to this window for drawing */
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- if (gc->isAttached)
-#if 1
- {
- GLWIN_DEBUG_MSG("context is already bound! Adjusting HWND.\n");
- glWinAdjustHWND(gc, pWin);
- continue;
- }
-#else
- unattach(gc);
-#endif
- attach(gc, glPriv);
- }
-
- /* GL contexts bound to this window for reading */
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- if (gc->isAttached)
-#if 1
- {
- GLWIN_DEBUG_MSG("context is already bound! Adjusting HWND.\n");
- glWinAdjustHWND(gc, pWin);
- continue;
- }
-#else
- unattach(gc);
-#endif
- attach(gc, glPriv);
- }
- }
-
- return result;
-}
-
-
-void
-glWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum];
- __GLXdrawablePrivate *glxPriv;
-
- GLWIN_TRACE_MSG(" (pWindow %p)\n", pWindow);
-
- /* Check if the window is attached and discard any drawing request */
- glxPriv = __glXFindDrawablePrivate(pWindow->drawable.id);
- if (glxPriv) {
- __GLXcontext *gx;
-
- /* GL contexts bound to this window for drawing */
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
-/*
- GLWIN_DEBUG_MSG("glWinCopyWindow - calling glDrawBuffer\n");
- glDrawBuffer(GL_FRONT);
- */
-
- return;
- }
-
- /* GL contexts bound to this window for reading */
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
- return;
- }
- }
-
- GLWIN_DEBUG_MSG("glWinCopyWindow - passing to hw layer\n");
-
- pScreen->CopyWindow = screenPriv->CopyWindow;
- pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
- pScreen->CopyWindow = glWinCopyWindow;
-}
-
-Bool
-glWinUnrealizeWindow(WindowPtr pWin)
-{
- /* If this window has GL contexts, tell them to unattach */
- Bool result;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- glWinScreenRec *screenPriv = &glWinScreens[pScreen->myNum];
- __GLXdrawablePrivate *glxPriv;
-
- GLWIN_DEBUG_MSG("glWinUnrealizeWindow\n");
-
- /* The Aqua window may have already been destroyed (windows
- * are unrealized from top down)
- */
-
- /* Unattach this window's GL contexts, if any. */
- glxPriv = __glXFindDrawablePrivate(pWin->drawable.id);
- if (glxPriv) {
- __GLXcontext *gx;
- __GLcontext *gc;
- GLWIN_DEBUG_MSG("glWinUnealizeWindow is GL drawable!\n");
-
- /* GL contexts bound to this window for drawing */
- for (gx = glxPriv->drawGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- unattach(gc);
- }
-
- /* GL contexts bound to this window for reading */
- for (gx = glxPriv->readGlxc; gx != NULL; gx = gx->next) {
- gc = (__GLcontext *)gx->gc;
- unattach(gc);
- }
- }
-
- pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow;
- result = pScreen->UnrealizeWindow(pWin);
- pScreen->UnrealizeWindow = glWinUnrealizeWindow;
-
- return result;
-}
-
-
-/*
- * In the case the driver has no GLX visuals we'll use these.
- * [0] = RGB, double buffered
- * [1] = RGB, double buffered, stencil, accum
- */
-/* Originally copied from Mesa */
-
-static int numConfigs = 0;
-static __GLXvisualConfig *visualConfigs = NULL;
-static void **visualPrivates = NULL;
-
-#define NUM_FALLBACK_CONFIGS 2
-static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
- {
- -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_EXT, /* visualRating */
- 0, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- },
- {
- -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_EXT, /* visualRating */
- 0, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
- }
-};
-
-static __GLXvisualConfig NullConfig = {
- -1, /* vid */
- -1, /* class */
- False, /* rgba */
- -1, -1, -1, 0, /* rgba sizes */
- -1, -1, -1, 0, /* rgba masks */
- 0, 0, 0, 0, /* rgba accum sizes */
- False, /* doubleBuffer */
- False, /* stereo */
- -1, /* bufferSize */
- 16, /* depthSize */
- 0, /* stencilSize */
- 0, /* auxBuffers */
- 0, /* level */
- GLX_NONE_EXT, /* visualRating */
- 0, /* transparentPixel */
- 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
- 0 /* transparentIndex */
-};
-
-static inline int count_bits(uint32_t x)
-{
- x = x - ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0f0f0f0f;
- x = x + (x >> 8);
- x = x + (x >> 16);
- return x & 63;
-}
-
-/* Mostly copied from Mesa's xf86glx.c */
-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 = NULL;
- __GLXvisualConfig *pNewVisualConfigs = NULL;
- void **glXVisualPriv;
- void **pNewVisualPriv;
- int found_default;
- int i, j, k;
-
- GLWIN_DEBUG_MSG("init_visuals\n");
-
- 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++) {
- int count;
-
- count = ((pVisual[i].class == TrueColor
- || pVisual[i].class == DirectColor)
- ? numRGBconfigs : numCIconfigs);
- if (count == 0)
- count = 1; /* preserve the existing visual */
-
- numNewVisuals += count;
- }
-
- /* 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;
- glWinScreens[screenInfo.numScreens-1].modes = modes;
- for (i = j = 0; i < numVisuals; i++) {
- int is_rgb = (pVisual[i].class == TrueColor ||
- pVisual[i].class == DirectColor);
-
- if (!is_rgb)
- {
- /* We don't support non-rgb visuals for GL. But we don't
- want to remove them either, so just pass them through
- with null glX configs */
-
- 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, & NullConfig );
- modes->visualID = pVisualNew[j].vid;
-
- j++;
-
- continue;
- }
-
- 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 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 */
- glWinScreens[screenInfo.numScreens-1].num_vis = numNewVisuals;
- glWinScreens[screenInfo.numScreens-1].priv = 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)
- xfree(visualPrivates);
- visualPrivates = NULL;
-
- return TRUE;
-}
-
-
-static void fixup_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- glWinScreenRec *pScr = &glWinScreens[screen];
- __GLcontextModes *modes;
- int j;
-
- GLWIN_DEBUG_MSG("fixup_visuals\n");
-
- for (modes = pScr->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);
- 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);
- }
- }
- }
-}
-
-static void init_screen_visuals(int screen)
-{
- ScreenPtr pScreen = screenInfo.screens[screen];
- __GLcontextModes *modes;
- int *used;
- int i, j;
-
- GLWIN_DEBUG_MSG("init_screen_visuals\n");
-
- used = (int *)__glXMalloc(pScreen->numVisuals * sizeof(int));
- __glXMemset(used, 0, pScreen->numVisuals * sizeof(int));
-
- i = 0;
- for ( modes = glWinScreens[screen].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;
-
- for (j = 0; j < pScreen->numVisuals; j++) {
-
- if (pVis[j].class == vis_class &&
- pVis[j].nplanes == nplanes &&
- pVis[j].redMask == modes->redMask &&
- pVis[j].greenMask == modes->greenMask &&
- pVis[j].blueMask == modes->blueMask &&
- !used[j]) {
-
-#if 0
- /* Create the XMesa visual */
- pXMesaVisual[i] =
- XMesaCreateVisual(pScreen,
- pVis,
- modes->rgbMode,
- (modes->alphaBits > 0),
- modes->doubleBufferMode,
- modes->stereoMode,
- GL_TRUE, /* ximage_flag */
- modes->depthBits,
- modes->stencilBits,
- modes->accumRedBits,
- modes->accumGreenBits,
- modes->accumBlueBits,
- modes->accumAlphaBits,
- modes->samples,
- modes->level,
- modes->visualRating);
-#endif
-
- /* Set the VisualID */
- modes->visualID = pVis[j].vid;
-
- /* Mark this visual used */
- used[j] = 1;
- break;
- }
- }
-
- if ( j == pScreen->numVisuals ) {
- ErrorF("No matching visual for __GLcontextMode with "
- "visual class = %d (%d), nplanes = %u\n",
- vis_class,
- modes->visualType,
- (modes->rgbBits - modes->alphaBits) );
- }
- else if ( modes->visualID == -1 ) {
- FatalError( "Matching visual found, but visualID still -1!\n" );
- }
-
- i++;
-
- }
-
- __glXFree(used);
-
- /* glWinScreens[screen].xm_vis = pXMesaVisual; */
-}
-
-static Bool glWinScreenProbe(int screen)
-{
- ScreenPtr pScreen;
- glWinScreenRec *screenPriv;
-
- GLWIN_DEBUG_MSG("glWinScreenProbe\n");
-
- /*
- * Set up the current screen's visuals.
- */
- __glDDXScreenInfo.modes = glWinScreens[screen].modes;
- __glDDXScreenInfo.pVisualPriv = glWinScreens[screen].priv;
- __glDDXScreenInfo.numVisuals =
- __glDDXScreenInfo.numUsableVisuals = glWinScreens[screen].num_vis;
-
- /*
- * Set the current screen's createContext routine. This could be
- * wrapped by a DDX GLX context creation routine.
- */
- __glDDXScreenInfo.createContext = glWinCreateContext;
-
- /*
- * The ordering of the rgb compenents might have been changed by the
- * driver after mi initialized them.
- */
- fixup_visuals(screen);
-
- /*
- * Find the GLX visuals that are supported by this screen and create
- * XMesa's visuals.
- */
- init_screen_visuals(screen);
-
- /* Wrap RealizeWindow and UnrealizeWindow on this screen */
- pScreen = screenInfo.screens[screen];
- screenPriv = &glWinScreens[screen];
- screenPriv->RealizeWindow = pScreen->RealizeWindow;
- pScreen->RealizeWindow = glWinRealizeWindow;
- screenPriv->UnrealizeWindow = pScreen->UnrealizeWindow;
- pScreen->UnrealizeWindow = glWinUnrealizeWindow;
- screenPriv->CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = glWinCopyWindow;
-
- return TRUE;
-}
-
-static GLboolean glWinSwapBuffers(__GLXdrawablePrivate *glxPriv)
-{
- /* swap buffers on only *one* of the contexts
- * (e.g. the last one for drawing)
- */
- __GLcontext *gc = (__GLcontext *)glxPriv->drawGlxc->gc;
- HDC dc;
- BOOL ret;
-
- GLWIN_TRACE_MSG("glWinSwapBuffers (ctx %p)\n", (gc!=NULL?gc->ctx:NULL));
-
- if (gc != NULL && gc->ctx != NULL)
- {
- dc = glWinMakeDC(gc);
- if (dc == NULL)
- return GL_FALSE;
-
- ret = SwapBuffers(dc);
- if (!ret)
- ErrorF("SwapBuffers failed: %s\n", glWinErrorMessage());
-
- ReleaseDC(gc->winInfo.hwnd, dc);
- if (!ret)
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-static void glWinDestroyDrawablePrivate(__GLdrawablePrivate *glPriv)
-{
- GLWIN_DEBUG_MSG("glWinDestroyDrawablePrivate\n");
-
- /* It doesn't work to call DRIDestroySurface here, the drawable's
- already gone.. But dri.c notices the window destruction and
- frees the surface itself. */
-
- free(glPriv->private);
- glPriv->private = NULL;
-}
-
-
-static void glWinCreateBuffer(__GLXdrawablePrivate *glxPriv)
-{
- GLWinDrawableRec *winPriv = malloc(sizeof(GLWinDrawableRec));
- __GLdrawablePrivate *glPriv = &glxPriv->glPriv;
-
- /*winPriv->sid = 0; */
- winPriv->pDraw = NULL;
-
- GLWIN_DEBUG_MSG("glWinCreateBuffer\n");
-
- /* replace swapBuffers (original is never called) */
- glxPriv->swapBuffers = glWinSwapBuffers;
-
- /* stash private data */
- glPriv->private = winPriv;
- glPriv->freePrivate = glWinDestroyDrawablePrivate;
-}
-
-static void glWinResetExtension(void)
-{
- GLWIN_DEBUG_MSG("glWinResetExtension\n");
-}
-
-/* based on code in apples/indirect.c which is based on i830_dri.c */
-static void
-glWinInitVisualConfigs(void)
-{
- int lclNumConfigs = 0;
- __GLXvisualConfig *lclVisualConfigs = NULL;
- void **lclVisualPrivates = NULL;
-
- int depth, aux, buffers, stencil, accum;
- int i = 0;
-
- GLWIN_DEBUG_MSG("glWinInitVisualConfigs ");
-
- /* count num configs:
- 2 Z buffer (0, 24 bit)
- 2 AUX buffer (0, 2)
- 2 buffers (single, double)
- 2 stencil (0, 8 bit)
- 2 accum (0, 64 bit)
- = 32 configs */
-
- lclNumConfigs = 2 * 2 * 2 * 2 * 2; /* 32 */
-
- /* alloc */
- lclVisualConfigs = xcalloc(sizeof(__GLXvisualConfig), lclNumConfigs);
- lclVisualPrivates = xcalloc(sizeof(void *), lclNumConfigs);
-
- /* fill in configs */
- if (NULL != lclVisualConfigs) {
- i = 0; /* current buffer */
- for (depth = 0; depth < 2; depth++) {
- for (aux = 0; aux < 2; aux++) {
- for (buffers = 0; buffers < 2; buffers++) {
- for (stencil = 0; stencil < 2; stencil++) {
- for (accum = 0; accum < 2; accum++) {
- lclVisualConfigs[i].vid = -1;
- lclVisualConfigs[i].class = -1;
- lclVisualConfigs[i].rgba = TRUE;
- lclVisualConfigs[i].redSize = -1;
- lclVisualConfigs[i].greenSize = -1;
- lclVisualConfigs[i].blueSize = -1;
- lclVisualConfigs[i].redMask = -1;
- lclVisualConfigs[i].greenMask = -1;
- lclVisualConfigs[i].blueMask = -1;
- lclVisualConfigs[i].alphaMask = 0;
- if (accum) {
- lclVisualConfigs[i].accumRedSize = 16;
- lclVisualConfigs[i].accumGreenSize = 16;
- lclVisualConfigs[i].accumBlueSize = 16;
- lclVisualConfigs[i].accumAlphaSize = 16;
- }
- else {
- lclVisualConfigs[i].accumRedSize = 0;
- lclVisualConfigs[i].accumGreenSize = 0;
- lclVisualConfigs[i].accumBlueSize = 0;
- lclVisualConfigs[i].accumAlphaSize = 0;
- }
- lclVisualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
- lclVisualConfigs[i].stereo = FALSE;
- lclVisualConfigs[i].bufferSize = -1;
-
- lclVisualConfigs[i].depthSize = depth? 24 : 0;
- lclVisualConfigs[i].stencilSize = stencil ? 8 : 0;
- lclVisualConfigs[i].auxBuffers = aux ? 2 : 0;
- lclVisualConfigs[i].level = 0;
- lclVisualConfigs[i].visualRating = GLX_NONE_EXT;
- lclVisualConfigs[i].transparentPixel = 0;
- lclVisualConfigs[i].transparentRed = 0;
- lclVisualConfigs[i].transparentGreen = 0;
- lclVisualConfigs[i].transparentBlue = 0;
- lclVisualConfigs[i].transparentAlpha = 0;
- lclVisualConfigs[i].transparentIndex = 0;
- i++;
- }
- }
- }
- }
- }
- }
- if (i != lclNumConfigs)
- GLWIN_DEBUG_MSG("glWinInitVisualConfigs failed to alloc visual configs");
-
- GlxSetVisualConfigs(lclNumConfigs, lclVisualConfigs, lclVisualPrivates);
-}
-
-/* Copied from Mesa */
-static void glWinSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
- void **privates)
-{
- GLWIN_DEBUG_MSG("glWinSetVisualConfigs\n");
-
- numConfigs = nconfigs;
- visualConfigs = configs;
- visualPrivates = privates;
-}
-
-/* Copied from Mesa */
-static Bool glWinInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
- int *nvisualp, int *ndepthp,
- int *rootDepthp, VisualID *defaultVisp,
- unsigned long sizes, int bitsPerRGB)
-{
- glWinInitDebugSettings();
-
- GLWIN_DEBUG_MSG("glWinInitVisuals\n");
-
- if (0 == numConfigs) /* if no configs */
- glWinInitVisualConfigs(); /* ensure the visula configs are setup */
-
- /*
- * Setup the visuals supported by this particular screen.
- */
- return init_visuals(nvisualp, visualp, defaultVisp,
- *ndepthp, *depthp, *rootDepthp);
-}