mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-03-21 08:40:36 +01:00
Update to new GLX interface
This commit is contained in:
parent
ad89f1032a
commit
9fb911fe06
43 changed files with 3074 additions and 2748 deletions
43
ChangeLog
43
ChangeLog
|
|
@ -1,3 +1,46 @@
|
|||
2006-03-08 David Reveman <davidr@novell.com>
|
||||
|
||||
* GL/symlink-mesa.sh:
|
||||
* GL/glx/Makefile.am:
|
||||
* GL/glx/g_disptab.h:
|
||||
* GL/glx/global.c:
|
||||
* GL/glx/glxcmds.c:
|
||||
* GL/glx/glxcmdsswap.c:
|
||||
* GL/glx/glxcontext.h:
|
||||
* GL/glx/glxdrawable.h:
|
||||
* GL/glx/glxext.c:
|
||||
* GL/glx/glximports.c:
|
||||
* GL/glx/glxscreens.c:
|
||||
* GL/glx/glxscreens.h:
|
||||
* GL/glx/glxserver.h:
|
||||
* GL/glx/glxutil.c:
|
||||
* GL/glx/glxutil.h:
|
||||
* GL/glx/indirect_util.c:
|
||||
* GL/glx/render2swap.c:
|
||||
* GL/glx/single2.c:
|
||||
* GL/include/GL/glx_ansic.h:
|
||||
* GL/include/GL/xf86glx.h:
|
||||
* GL/mesa/Makefile.am:
|
||||
* GL/mesa/X/Makefile.am:
|
||||
* GL/mesa/X/xf86glx.c:
|
||||
* GL/mesa/X/xf86glx_util.c:
|
||||
* GL/mesa/X/xf86glxint.h:
|
||||
* GL/mesa/array_cache/Makefile.am:
|
||||
* GL/mesa/glapi/Makefile.am:
|
||||
* GL/mesa/main/Makefile.am:
|
||||
* GL/mesa/math/Makefile.am:
|
||||
* GL/mesa/shader/Makefile.am:
|
||||
* GL/mesa/shader/grammar/Makefile.am:
|
||||
* GL/mesa/shader/slang/Makefile.am:
|
||||
* GL/mesa/swrast/Makefile.am:
|
||||
* GL/mesa/swrast_setup/Makefile.am:
|
||||
* GL/mesa/tnl/Makefile.am:
|
||||
* hw/xgl/xglglx.c:
|
||||
* hw/xgl/xglglx.h:
|
||||
* hw/xgl/glxext/xglglxext.c:
|
||||
* hw/xgl/glxext/module/Makefile.am:
|
||||
Update to new GLX interface.
|
||||
|
||||
2006-03-06 David Reveman <davidr@novell.com>
|
||||
|
||||
* GL/symlink-mesa.sh: Add s_blit.c.
|
||||
|
|
|
|||
|
|
@ -1,23 +1,41 @@
|
|||
noinst_LTLIBRARIES = libglx.la
|
||||
if DRI
|
||||
GLXDRI_LIBRARY=libglxdri.la
|
||||
endif
|
||||
|
||||
noinst_LTLIBRARIES = libglx.la $(GLXDRI_LIBRARY)
|
||||
|
||||
AM_CFLAGS = \
|
||||
-I@MESA_SOURCE@/include \
|
||||
@DIX_CFLAGS@ \
|
||||
@GL_CFLAGS@ \
|
||||
@XLIB_CFLAGS@ \
|
||||
-I@MESA_SOURCE@/include \
|
||||
@LIBDRM_CFLAGS@ \
|
||||
@DRIPROTO_CFLAGS@ \
|
||||
-I@MESA_SOURCE@/src/mesa/glapi \
|
||||
-I@MESA_SOURCE@/src/mesa/main \
|
||||
@SERVER_DEFINES@ \
|
||||
@MODULE_DEFINES@ \
|
||||
@LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
@LOADER_DEFINES@ \
|
||||
-DNO_LIBCWRAPPER \
|
||||
-DUSE_MGL_NAMESPACE
|
||||
|
||||
# none yet
|
||||
#sdk_HEADERS =
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/GL/include -I$(top_srcdir)/hw/xfree86/os-support
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/GL/include \
|
||||
-I$(top_srcdir)/hw/xfree86/os-support \
|
||||
-I$(top_srcdir)/hw/xfree86/os-support/bus \
|
||||
-I$(top_srcdir)/hw/xfree86/common \
|
||||
-I$(top_srcdir)/hw/xfree86/dri \
|
||||
-I$(top_srcdir)/mi
|
||||
|
||||
|
||||
nodist_libglx_la_SOURCES = indirect_size.h
|
||||
|
||||
libglxdri_la_SOURCES = \
|
||||
glxdri.c
|
||||
|
||||
libglx_la_SOURCES = \
|
||||
g_disptab.c \
|
||||
g_disptab.h \
|
||||
|
|
@ -28,8 +46,6 @@ libglx_la_SOURCES = \
|
|||
glcontextmodes.h \
|
||||
global.c \
|
||||
glthread.c \
|
||||
glxbuf.c \
|
||||
glxbuf.h \
|
||||
glxcmds.c \
|
||||
glxcmdsswap.c \
|
||||
glxcontext.h \
|
||||
|
|
@ -37,14 +53,7 @@ libglx_la_SOURCES = \
|
|||
glxerror.h \
|
||||
glxext.c \
|
||||
glxext.h \
|
||||
glxfb.c \
|
||||
glxfb.h \
|
||||
glximports.c \
|
||||
glximports.h \
|
||||
glxmem.c \
|
||||
glxmem.h \
|
||||
glxpix.c \
|
||||
glxpix.h \
|
||||
glxvisuals.c \
|
||||
glxscreens.c \
|
||||
glxscreens.h \
|
||||
glxserver.h \
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ extern int __glXWaitGL(__GLXclientState*, GLbyte*);
|
|||
extern int __glXWaitX(__GLXclientState*, GLbyte*);
|
||||
extern int __glXCopyContext(__GLXclientState*, GLbyte*);
|
||||
extern int __glXSwapBuffers(__GLXclientState*, GLbyte*);
|
||||
extern int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc);
|
||||
extern int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc);
|
||||
extern int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc);
|
||||
extern int __glXUseXFont(__GLXclientState*, GLbyte*);
|
||||
extern int __glXCreateGLXPixmap(__GLXclientState*, GLbyte*);
|
||||
extern int __glXGetVisualConfigs(__GLXclientState*, GLbyte*);
|
||||
|
|
@ -71,6 +74,9 @@ extern int __glXSwapWaitGL(__GLXclientState*, GLbyte*);
|
|||
extern int __glXSwapWaitX(__GLXclientState*, GLbyte*);
|
||||
extern int __glXSwapCopyContext(__GLXclientState*, GLbyte*);
|
||||
extern int __glXSwapSwapBuffers(__GLXclientState*, GLbyte*);
|
||||
extern int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLbyte *pc);
|
||||
extern int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc);
|
||||
extern int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc);
|
||||
extern int __glXSwapUseXFont(__GLXclientState*, GLbyte*);
|
||||
extern int __glXSwapCreateGLXPixmap(__GLXclientState*, GLbyte*);
|
||||
extern int __glXSwapGetVisualConfigs(__GLXclientState*, GLbyte*);
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ __GLXcontext *__glXLastContext;
|
|||
RESTYPE __glXContextRes;
|
||||
RESTYPE __glXClientRes;
|
||||
RESTYPE __glXPixmapRes;
|
||||
RESTYPE __glXDrawableRes;
|
||||
RESTYPE __glXSwapBarrierRes;
|
||||
|
||||
/*
|
||||
|
|
|
|||
383
GL/glx/glxcmds.c
383
GL/glx/glxcmds.c
|
|
@ -40,6 +40,8 @@
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "glxserver.h"
|
||||
#include <GL/glxtokens.h>
|
||||
#include <unpack.h>
|
||||
|
|
@ -47,7 +49,6 @@
|
|||
#include <pixmapstr.h>
|
||||
#include <windowstr.h>
|
||||
#include "g_disptab_EXT.h"
|
||||
#include "glximports.h"
|
||||
#include "glxutil.h"
|
||||
#include "glxext.h"
|
||||
#include "GL/glx_ansic.h"
|
||||
|
|
@ -57,31 +58,22 @@
|
|||
#include "glthread.h"
|
||||
#include "dispatch.h"
|
||||
|
||||
#ifndef GLX_TEXTURE_TARGET_EXT
|
||||
#define GLX_TEXTURE_TARGET_EXT 0x6001
|
||||
#define GLX_TEXTURE_2D_EXT 0x6002
|
||||
#define GLX_TEXTURE_RECTANGLE_EXT 0x6003
|
||||
#define GLX_NO_TEXTURE_EXT 0x6004
|
||||
#define GLX_Y_INVERTED_EXT 0x6006
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
void GlxSetRenderTables (struct _glapi_table *table)
|
||||
void
|
||||
GlxSetRenderTables (struct _glapi_table *table)
|
||||
{
|
||||
_glapi_set_dispatch(table);
|
||||
_glapi_set_dispatch (table);
|
||||
}
|
||||
|
||||
static __GLimports imports = {
|
||||
__glXImpMalloc,
|
||||
__glXImpCalloc,
|
||||
__glXImpRealloc,
|
||||
__glXImpFree,
|
||||
__glXImpWarning,
|
||||
__glXImpFatal,
|
||||
__glXImpGetenv,
|
||||
__glXImpAtoi,
|
||||
__glXImpSprintf,
|
||||
__glXImpFopen,
|
||||
__glXImpFclose,
|
||||
__glXImpFprintf,
|
||||
__glXImpGetDrawablePrivate,
|
||||
__glXImpGetReadablePrivate,
|
||||
NULL
|
||||
};
|
||||
|
||||
static int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
|
||||
static int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
|
||||
static int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc);
|
||||
|
|
@ -97,6 +89,27 @@ static int __glxHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc);
|
|||
|
||||
/************************************************************************/
|
||||
|
||||
static void __glXdirectContextDestroy(__GLXcontext *context)
|
||||
{
|
||||
__glXFree(context);
|
||||
}
|
||||
|
||||
static __GLXcontext *__glXdirectContextCreate(__GLXscreen *screen,
|
||||
__GLcontextModes *modes,
|
||||
__GLXcontext *shareContext)
|
||||
{
|
||||
__GLXcontext *context;
|
||||
|
||||
context = __glXMalloc (sizeof (__GLXcontext));
|
||||
if (context == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(context, 0, sizeof *context);
|
||||
context->destroy = __glXdirectContextDestroy;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a GL context with the given properties. This routine is used
|
||||
* to implement \c glXCreateContext, \c glXCreateNewContext, and
|
||||
|
|
@ -114,8 +127,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
|||
ScreenPtr pScreen;
|
||||
__GLXcontext *glxc, *shareglxc;
|
||||
__GLcontextModes *modes;
|
||||
__GLXscreenInfo *pGlxScreen;
|
||||
__GLinterface *shareGC;
|
||||
__GLXscreen *pGlxScreen;
|
||||
GLint i;
|
||||
|
||||
LEGAL_NEW_RESOURCE(gcId, client);
|
||||
|
|
@ -128,7 +140,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
|||
return BadValue;
|
||||
}
|
||||
pScreen = screenInfo.screens[screen];
|
||||
pGlxScreen = &__glXActiveScreens[screen];
|
||||
pGlxScreen = __glXActiveScreens[screen];
|
||||
|
||||
/*
|
||||
** Check if the visual ID is valid for this screen.
|
||||
|
|
@ -170,7 +182,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
|||
** for multithreaded servers, we don't do this.
|
||||
*/
|
||||
if (shareList == None) {
|
||||
shareGC = 0;
|
||||
shareglxc = 0;
|
||||
} else {
|
||||
shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes);
|
||||
if (!shareglxc) {
|
||||
|
|
@ -196,17 +208,18 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
|||
*/
|
||||
isDirect = GL_FALSE;
|
||||
}
|
||||
shareGC = shareglxc->gc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Allocate memory for the new context
|
||||
*/
|
||||
glxc = (__GLXcontext *) __glXMalloc(sizeof(__GLXcontext));
|
||||
if (!isDirect)
|
||||
glxc = pGlxScreen->createContext(pGlxScreen, modes, shareglxc);
|
||||
else
|
||||
glxc = __glXdirectContextCreate(pGlxScreen, modes, shareglxc);
|
||||
if (!glxc) {
|
||||
return BadAlloc;
|
||||
}
|
||||
__glXMemset(glxc, 0, sizeof(__GLXcontext));
|
||||
|
||||
/*
|
||||
** Initially, setup the part of the context that could be used by
|
||||
|
|
@ -217,32 +230,11 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId,
|
|||
glxc->pVisual = pVisual;
|
||||
glxc->modes = modes;
|
||||
|
||||
if (!isDirect) {
|
||||
|
||||
/*
|
||||
** Allocate a GL context
|
||||
*/
|
||||
imports.other = (void *)glxc;
|
||||
glxc->gc = (*pGlxScreen->createContext)(&imports, glxc->modes, shareGC);
|
||||
if (!glxc->gc) {
|
||||
__glXFree(glxc);
|
||||
client->errorValue = gcId;
|
||||
return BadAlloc;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
** Don't need local GL context for a direct context.
|
||||
*/
|
||||
glxc->gc = 0;
|
||||
}
|
||||
/*
|
||||
** Register this context as a resource.
|
||||
*/
|
||||
if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
|
||||
if (!isDirect) {
|
||||
(*glxc->gc->exports.destroyContext)((__GLcontext *)glxc->gc);
|
||||
}
|
||||
__glXFree(glxc);
|
||||
(*glxc->destroy)(glxc);
|
||||
client->errorValue = gcId;
|
||||
return BadAlloc;
|
||||
}
|
||||
|
|
@ -523,9 +515,8 @@ int DoMakeCurrent( __GLXclientState *cl,
|
|||
__GLXpixmap *drawPixmap = NULL;
|
||||
__GLXpixmap *readPixmap = NULL;
|
||||
__GLXcontext *glxc, *prevglxc;
|
||||
__GLinterface *gc, *prevgc;
|
||||
__GLXdrawablePrivate *drawPriv = NULL;
|
||||
__GLXdrawablePrivate *readPriv = NULL;
|
||||
__GLXdrawable *drawPriv = NULL;
|
||||
__GLXdrawable *readPriv = NULL;
|
||||
GLint error;
|
||||
GLuint mask;
|
||||
|
||||
|
|
@ -557,10 +548,8 @@ int DoMakeCurrent( __GLXclientState *cl,
|
|||
client->errorValue = prevglxc->id;
|
||||
return __glXBadContextState;
|
||||
}
|
||||
prevgc = prevglxc->gc;
|
||||
} else {
|
||||
prevglxc = 0;
|
||||
prevgc = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -578,8 +567,6 @@ int DoMakeCurrent( __GLXclientState *cl,
|
|||
/* Context is current to somebody else */
|
||||
return BadAccess;
|
||||
}
|
||||
gc = glxc->gc;
|
||||
|
||||
|
||||
assert( drawId != None );
|
||||
assert( readId != None );
|
||||
|
|
@ -603,14 +590,14 @@ int DoMakeCurrent( __GLXclientState *cl,
|
|||
/* FIXME: Finish refactoring this. - idr */
|
||||
/* get the drawable private */
|
||||
if (pDraw) {
|
||||
drawPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes);
|
||||
drawPriv = __glXGetDrawable(glxc, pDraw, drawId);
|
||||
if (drawPriv == NULL) {
|
||||
return __glXBadDrawable;
|
||||
}
|
||||
}
|
||||
|
||||
if (pRead != pDraw) {
|
||||
readPriv = __glXGetDrawablePrivate(pRead, readId, glxc->modes);
|
||||
readPriv = __glXGetDrawable(glxc, pRead, readId);
|
||||
if (readPriv == NULL) {
|
||||
return __glXBadDrawable;
|
||||
}
|
||||
|
|
@ -621,7 +608,6 @@ int DoMakeCurrent( __GLXclientState *cl,
|
|||
} else {
|
||||
/* Switching to no context. Ignore new drawable. */
|
||||
glxc = 0;
|
||||
gc = 0;
|
||||
pDraw = 0;
|
||||
pRead = 0;
|
||||
}
|
||||
|
|
@ -643,7 +629,7 @@ int DoMakeCurrent( __GLXclientState *cl,
|
|||
/*
|
||||
** Make the previous context not current.
|
||||
*/
|
||||
if (!(*prevgc->exports.loseCurrent)((__GLcontext *)prevgc)) {
|
||||
if (!(*prevglxc->loseCurrent)(prevglxc)) {
|
||||
return __glXBadContext;
|
||||
}
|
||||
__glXDeassociateContext(prevglxc);
|
||||
|
|
@ -654,19 +640,18 @@ int DoMakeCurrent( __GLXclientState *cl,
|
|||
|
||||
glxc->drawPriv = drawPriv;
|
||||
glxc->readPriv = readPriv;
|
||||
__glXCacheDrawableSize(drawPriv);
|
||||
|
||||
/* make the context current */
|
||||
if (!(*gc->exports.makeCurrent)((__GLcontext *)gc)) {
|
||||
if (!(*glxc->makeCurrent)(glxc)) {
|
||||
glxc->drawPriv = NULL;
|
||||
glxc->readPriv = NULL;
|
||||
return __glXBadContext;
|
||||
}
|
||||
|
||||
/* resize the buffers */
|
||||
if (!__glXResizeDrawableBuffers(drawPriv)) {
|
||||
if (!(*drawPriv->resize)(drawPriv)) {
|
||||
/* could not do initial resize. make current failed */
|
||||
(*gc->exports.loseCurrent)((__GLcontext *)gc);
|
||||
(*glxc->loseCurrent)(glxc);
|
||||
glxc->drawPriv = NULL;
|
||||
glxc->readPriv = NULL;
|
||||
return __glXBadContext;
|
||||
|
|
@ -914,9 +899,7 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
|
|||
/*
|
||||
** Issue copy. The only reason for failure is a bad mask.
|
||||
*/
|
||||
if (!(*dst->gc->exports.copyContext)((__GLcontext *)dst->gc,
|
||||
(__GLcontext *)src->gc,
|
||||
mask)) {
|
||||
if (!(*dst->copy)(dst, src, mask)) {
|
||||
client->errorValue = mask;
|
||||
return BadValue;
|
||||
}
|
||||
|
|
@ -929,7 +912,7 @@ int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
|
|||
{
|
||||
ClientPtr client = cl->client;
|
||||
xGLXGetVisualConfigsReply reply;
|
||||
__GLXscreenInfo *pGlxScreen;
|
||||
__GLXscreen *pGlxScreen;
|
||||
__GLcontextModes *modes;
|
||||
CARD32 buf[__GLX_TOTAL_CONFIG];
|
||||
int p;
|
||||
|
|
@ -941,7 +924,7 @@ int DoGetVisualConfigs(__GLXclientState *cl, unsigned screen,
|
|||
client->errorValue = screen;
|
||||
return BadValue;
|
||||
}
|
||||
pGlxScreen = &__glXActiveScreens[screen];
|
||||
pGlxScreen = __glXActiveScreens[screen];
|
||||
|
||||
reply.numVisuals = pGlxScreen->numUsableVisuals;
|
||||
reply.numProps = __GLX_TOTAL_CONFIG;
|
||||
|
|
@ -1020,6 +1003,68 @@ int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
|
|||
}
|
||||
|
||||
|
||||
/* Composite adds a 32 bit ARGB visual after glxvisuals.c have created
|
||||
* the context modes for the screens. This visual is useful for GLX
|
||||
* pixmaps, so we create a single mode for this visual with no extra
|
||||
* buffers. */
|
||||
static void
|
||||
__glXCreateARGBConfig(__GLXscreen *screen)
|
||||
{
|
||||
__GLcontextModes *modes;
|
||||
VisualPtr visual;
|
||||
int i;
|
||||
|
||||
visual = NULL;
|
||||
for (i = 0; i < screen->pScreen->numVisuals; i++)
|
||||
if (screen->pScreen->visuals[i].nplanes == 32) {
|
||||
visual = &screen->pScreen->visuals[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (visual == NULL || visual->class != TrueColor)
|
||||
return;
|
||||
|
||||
if (_gl_context_modes_find_visual (screen->modes, visual->vid))
|
||||
return;
|
||||
|
||||
/* Stop now if we already added the mode. */
|
||||
modes = _gl_context_modes_create(1, sizeof(__GLcontextModes));
|
||||
if (modes == NULL)
|
||||
return;
|
||||
|
||||
modes->next = screen->modes;
|
||||
screen->modes = modes;
|
||||
screen->numUsableVisuals++;
|
||||
screen->numVisuals++;
|
||||
|
||||
modes->visualID = visual->vid;
|
||||
modes->fbconfigID = visual->vid;
|
||||
modes->visualType = GLX_TRUE_COLOR;
|
||||
modes->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
|
||||
modes->renderType = GLX_RGBA_BIT;
|
||||
modes->xRenderable = GL_TRUE;
|
||||
modes->rgbMode = TRUE;
|
||||
modes->colorIndexMode = FALSE;
|
||||
modes->doubleBufferMode = FALSE;
|
||||
modes->stereoMode = FALSE;
|
||||
modes->haveAccumBuffer = FALSE;
|
||||
|
||||
modes->redBits = visual->bitsPerRGBValue;;
|
||||
modes->greenBits = visual->bitsPerRGBValue;
|
||||
modes->blueBits = visual->bitsPerRGBValue;
|
||||
modes->alphaBits = visual->bitsPerRGBValue;
|
||||
|
||||
modes->rgbBits = 4 * visual->bitsPerRGBValue;
|
||||
modes->indexBits = 0;
|
||||
modes->level = 0;
|
||||
modes->numAuxBuffers = 0;
|
||||
|
||||
modes->haveDepthBuffer = FALSE;
|
||||
modes->depthBits = 0;
|
||||
modes->haveStencilBuffer = FALSE;
|
||||
modes->stencilBits = 0;
|
||||
}
|
||||
|
||||
|
||||
#define __GLX_TOTAL_FBCONFIG_ATTRIBS (28)
|
||||
#define __GLX_FBCONFIG_ATTRIBS_LENGTH (__GLX_TOTAL_FBCONFIG_ATTRIBS * 2)
|
||||
|
|
@ -1037,7 +1082,7 @@ int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap)
|
|||
{
|
||||
ClientPtr client = cl->client;
|
||||
xGLXGetFBConfigsReply reply;
|
||||
__GLXscreenInfo *pGlxScreen;
|
||||
__GLXscreen *pGlxScreen;
|
||||
CARD32 buf[__GLX_FBCONFIG_ATTRIBS_LENGTH];
|
||||
int p;
|
||||
__GLcontextModes *modes;
|
||||
|
|
@ -1050,7 +1095,9 @@ int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap)
|
|||
client->errorValue = screen;
|
||||
return BadValue;
|
||||
}
|
||||
pGlxScreen = &__glXActiveScreens[screen];
|
||||
pGlxScreen = __glXActiveScreens[screen];
|
||||
|
||||
__glXCreateARGBConfig(pGlxScreen);
|
||||
|
||||
reply.numFBConfigs = pGlxScreen->numUsableVisuals;
|
||||
reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS;
|
||||
|
|
@ -1148,7 +1195,7 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
|
|||
ScreenPtr pScreen;
|
||||
VisualPtr pVisual;
|
||||
__GLXpixmap *pGlxPixmap;
|
||||
__GLXscreenInfo *pGlxScreen;
|
||||
__GLXscreen *pGlxScreen;
|
||||
__GLcontextModes *modes;
|
||||
int i;
|
||||
|
||||
|
|
@ -1191,7 +1238,7 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
|
|||
/*
|
||||
** Get configuration of the visual.
|
||||
*/
|
||||
pGlxScreen = &__glXActiveScreens[screenNum];
|
||||
pGlxScreen = __glXActiveScreens[screenNum];
|
||||
modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual );
|
||||
if (modes == NULL) {
|
||||
/*
|
||||
|
|
@ -1216,29 +1263,11 @@ int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual,
|
|||
|
||||
pGlxPixmap->modes = modes;
|
||||
|
||||
/*
|
||||
** Allocate buffers.
|
||||
*/
|
||||
pGlxPixmap->glxPriv = __glXCreateDrawablePrivate (pDraw, glxpixmapId,
|
||||
modes);
|
||||
if (!pGlxPixmap->glxPriv)
|
||||
{
|
||||
FreeResource(glxpixmapId, FALSE);
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
__glXRefDrawablePrivate (pGlxPixmap->glxPriv);
|
||||
/*
|
||||
** Bump the ref count on the X pixmap so it won't disappear.
|
||||
*/
|
||||
((PixmapPtr) pDraw)->refcnt++;
|
||||
|
||||
/*
|
||||
** XXX: Reset refcnt. Ignores references to this pixmap made by
|
||||
** __glXCreateDrawablePrivate. Need to fix this.
|
||||
*/
|
||||
pGlxPixmap->refcnt = 0;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
|
@ -1362,16 +1391,16 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
|
|||
}
|
||||
|
||||
if (pDraw) {
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
__GLXdrawable *glxPriv;
|
||||
|
||||
if (glxc) {
|
||||
glxPriv = __glXGetDrawablePrivate(pDraw, drawId, glxc->modes);
|
||||
glxPriv = __glXGetDrawable(glxc, pDraw, drawId);
|
||||
if (glxPriv == NULL) {
|
||||
return __glXBadDrawable;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glxPriv = __glXFindDrawablePrivate(drawId);
|
||||
glxPriv = __glXFindDrawable(drawId);
|
||||
if (glxPriv == NULL) {
|
||||
/* This is a window we've never seen before, do nothing */
|
||||
return Success;
|
||||
|
|
@ -1434,55 +1463,13 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
|
|||
return Success;
|
||||
}
|
||||
|
||||
int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
|
||||
{
|
||||
xGLXGetDrawableAttributesReply reply;
|
||||
ClientPtr client = cl->client;
|
||||
GLXDrawable drawId;
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
int numAttribs;
|
||||
int sendBuf[2];
|
||||
|
||||
pc += __GLX_VENDPRIV_HDR_SIZE;
|
||||
|
||||
drawId = *((GLXDrawable *) (pc));
|
||||
|
||||
glxPriv = __glXFindDrawablePrivate (drawId);
|
||||
if (!glxPriv)
|
||||
{
|
||||
client->errorValue = drawId;
|
||||
return __glXBadDrawable;
|
||||
}
|
||||
|
||||
numAttribs = 1; /* XXX: Only GLX_TEXTURE_TARGET_EXT right now */
|
||||
reply.length = numAttribs << 1;
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
reply.numAttribs = numAttribs;
|
||||
|
||||
sendBuf[0] = GLX_TEXTURE_TARGET_EXT;
|
||||
sendBuf[1] = (int) (glxPriv->texTarget);
|
||||
|
||||
if (client->swapped)
|
||||
{
|
||||
__glXSwapGetDrawableAttributesReply (client, &reply, sendBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToClient (client, sz_xGLXGetDrawableAttributesReply,
|
||||
(char *) &reply);
|
||||
WriteToClient (client, sizeof (sendBuf), (char *) sendBuf);
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
|
||||
{
|
||||
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
|
||||
ClientPtr client = cl->client;
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
__GLXcontext *cx;
|
||||
__GLXpixmap *pGlxPixmap;
|
||||
__GLXcontext *context;
|
||||
GLXDrawable drawId;
|
||||
int buffer;
|
||||
int error;
|
||||
|
|
@ -1492,26 +1479,33 @@ int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
|
|||
drawId = *((CARD32 *) (pc));
|
||||
buffer = *((INT32 *) (pc + 4));
|
||||
|
||||
cx = __glXForceCurrent (cl, req->contextTag, &error);
|
||||
if (!cx)
|
||||
if (buffer != GLX_FRONT_LEFT_EXT)
|
||||
return __glXBadPixmap;
|
||||
|
||||
context = __glXForceCurrent (cl, req->contextTag, &error);
|
||||
if (!context)
|
||||
return error;
|
||||
|
||||
glxPriv = __glXFindDrawablePrivate (drawId);
|
||||
if (!glxPriv)
|
||||
{
|
||||
pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
|
||||
if (!pGlxPixmap) {
|
||||
client->errorValue = drawId;
|
||||
return __glXBadDrawable;
|
||||
return __glXBadPixmap;
|
||||
}
|
||||
|
||||
return (*glxPriv->bindBuffers) (glxPriv, buffer);
|
||||
|
||||
if (!context->textureFromPixmap)
|
||||
return __glXUnsupportedPrivateRequest;
|
||||
|
||||
return context->textureFromPixmap->bindTexImage(context,
|
||||
buffer,
|
||||
pGlxPixmap);
|
||||
}
|
||||
|
||||
int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
|
||||
{
|
||||
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
|
||||
ClientPtr client = cl->client;
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
__GLXcontext *cx;
|
||||
__GLXpixmap *pGlxPixmap;
|
||||
__GLXcontext *context;
|
||||
GLXDrawable drawId;
|
||||
int buffer;
|
||||
int error;
|
||||
|
|
@ -1521,20 +1515,85 @@ int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
|
|||
drawId = *((CARD32 *) (pc));
|
||||
buffer = *((INT32 *) (pc + 4));
|
||||
|
||||
cx = __glXForceCurrent (cl, req->contextTag, &error);
|
||||
if (!cx)
|
||||
context = __glXForceCurrent (cl, req->contextTag, &error);
|
||||
if (!context)
|
||||
return error;
|
||||
|
||||
glxPriv = __glXFindDrawablePrivate (drawId);
|
||||
if (!glxPriv)
|
||||
{
|
||||
pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
|
||||
if (!pGlxPixmap) {
|
||||
client->errorValue = drawId;
|
||||
return __glXBadDrawable;
|
||||
}
|
||||
|
||||
return (*glxPriv->releaseBuffers) (glxPriv, buffer);
|
||||
|
||||
if (!context->textureFromPixmap)
|
||||
return __glXUnsupportedPrivateRequest;
|
||||
|
||||
return context->textureFromPixmap->releaseTexImage(context,
|
||||
buffer,
|
||||
pGlxPixmap);
|
||||
}
|
||||
|
||||
/*
|
||||
** Get drawable attributes
|
||||
*/
|
||||
static int
|
||||
DoGetDrawableAttributes(__GLXclientState *cl, XID drawId)
|
||||
{
|
||||
ClientPtr client = cl->client;
|
||||
__GLXpixmap *glxPixmap;
|
||||
__GLXscreen *glxScreen;
|
||||
xGLXGetDrawableAttributesReply reply;
|
||||
CARD32 attributes[4];
|
||||
int numAttribs;
|
||||
|
||||
glxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes);
|
||||
if (!glxPixmap) {
|
||||
client->errorValue = drawId;
|
||||
return __glXBadPixmap;
|
||||
}
|
||||
|
||||
numAttribs = 2;
|
||||
reply.length = numAttribs << 1;
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
reply.numAttribs = numAttribs;
|
||||
|
||||
attributes[0] = GLX_TEXTURE_TARGET_EXT;
|
||||
attributes[1] = GLX_NO_TEXTURE_EXT;
|
||||
attributes[2] = GLX_Y_INVERTED_EXT;
|
||||
attributes[3] = GL_FALSE;
|
||||
|
||||
glxScreen = glxPixmap->pGlxScreen;
|
||||
if (glxScreen->textureFromPixmap)
|
||||
attributes[1] =
|
||||
(*glxScreen->textureFromPixmap->getTexTarget) (glxScreen,
|
||||
glxPixmap);
|
||||
|
||||
if (client->swapped) {
|
||||
__glXSwapGetDrawableAttributesReply(client, &reply, attributes);
|
||||
} else {
|
||||
WriteToClient(client, sz_xGLXGetDrawableAttributesReply,
|
||||
(char *)&reply);
|
||||
WriteToClient(client, reply.length * sizeof (CARD32),
|
||||
(char *)attributes);
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
|
||||
{
|
||||
xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc;
|
||||
CARD32 *data;
|
||||
XID drawable;
|
||||
|
||||
data = (CARD32 *) (req + 1);
|
||||
drawable = data[0];
|
||||
|
||||
return DoGetDrawableAttributes(cl, drawable);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
static int
|
||||
|
|
@ -2298,9 +2357,9 @@ int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc)
|
|||
case X_GLXvop_BindSwapBarrierSGIX:
|
||||
return __glXBindSwapBarrierSGIX(cl, pc);
|
||||
case X_GLXvop_BindTexImageEXT:
|
||||
return __glXBindTexImageEXT(cl, pc);
|
||||
return __glXBindTexImageEXT(cl, pc);
|
||||
case X_GLXvop_ReleaseTexImageEXT:
|
||||
return __glXReleaseTexImageEXT(cl, pc);
|
||||
return __glXReleaseTexImageEXT(cl, pc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -2396,7 +2455,7 @@ int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
|
|||
return BadValue;
|
||||
}
|
||||
|
||||
ptr = __glXActiveScreens[screen].GLXextensions;
|
||||
ptr = __glXActiveScreens[screen]->GLXextensions;
|
||||
|
||||
n = __glXStrlen(ptr) + 1;
|
||||
length = __GLX_PAD(n) >> 2;
|
||||
|
|
@ -2443,13 +2502,13 @@ int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
|
|||
}
|
||||
switch(name) {
|
||||
case GLX_VENDOR:
|
||||
ptr = __glXActiveScreens[screen].GLXvendor;
|
||||
ptr = __glXActiveScreens[screen]->GLXvendor;
|
||||
break;
|
||||
case GLX_VERSION:
|
||||
ptr = __glXActiveScreens[screen].GLXversion;
|
||||
ptr = __glXActiveScreens[screen]->GLXversion;
|
||||
break;
|
||||
case GLX_EXTENSIONS:
|
||||
ptr = __glXActiveScreens[screen].GLXextensions;
|
||||
ptr = __glXActiveScreens[screen]->GLXextensions;
|
||||
break;
|
||||
default:
|
||||
return BadValue;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "glxserver.h"
|
||||
#include "glxutil.h"
|
||||
#include <GL/glxtokens.h>
|
||||
|
|
@ -389,36 +390,18 @@ int __glXSwapQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
|
|||
return __glXQueryContextInfoEXT(cl, pc);
|
||||
}
|
||||
|
||||
int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, char *pc)
|
||||
int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLbyte *pc)
|
||||
{
|
||||
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
|
||||
GLXDrawable *drawId;
|
||||
int *buffer;
|
||||
|
||||
__GLX_DECLARE_SWAP_VARIABLES;
|
||||
|
||||
pc += __GLX_VENDPRIV_HDR_SIZE;
|
||||
|
||||
drawId = ((GLXDrawable *) (pc));
|
||||
|
||||
__GLX_SWAP_SHORT(&req->length);
|
||||
__GLX_SWAP_INT(&req->contextTag);
|
||||
__GLX_SWAP_INT(drawId);
|
||||
|
||||
return __glXGetDrawableAttributesSGIX(cl, (GLbyte *)pc);
|
||||
}
|
||||
|
||||
int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLchar *pc)
|
||||
{
|
||||
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
|
||||
CARD32 *drawId;
|
||||
INT32 *buffer;
|
||||
|
||||
__GLX_DECLARE_SWAP_VARIABLES;
|
||||
|
||||
pc += __GLX_VENDPRIV_HDR_SIZE;
|
||||
|
||||
drawId = ((CARD32 *) (pc));
|
||||
buffer = ((INT32 *) (pc + 4));
|
||||
buffer = ((int *) (pc + 4));
|
||||
|
||||
__GLX_SWAP_SHORT(&req->length);
|
||||
__GLX_SWAP_INT(&req->contextTag);
|
||||
|
|
@ -428,18 +411,18 @@ int __glXSwapBindTexImageEXT(__GLXclientState *cl, GLchar *pc)
|
|||
return __glXBindTexImageEXT(cl, (GLbyte *)pc);
|
||||
}
|
||||
|
||||
int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLchar *pc)
|
||||
int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc)
|
||||
{
|
||||
xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
|
||||
CARD32 *drawId;
|
||||
INT32 *buffer;
|
||||
GLXDrawable *drawId;
|
||||
int *buffer;
|
||||
|
||||
__GLX_DECLARE_SWAP_VARIABLES;
|
||||
|
||||
pc += __GLX_VENDPRIV_HDR_SIZE;
|
||||
|
||||
drawId = ((CARD32 *) (pc));
|
||||
buffer = ((INT32 *) (pc + 4));
|
||||
drawId = ((GLXDrawable *) (pc));
|
||||
buffer = ((int *) (pc + 4));
|
||||
|
||||
__GLX_SWAP_SHORT(&req->length);
|
||||
__GLX_SWAP_INT(&req->contextTag);
|
||||
|
|
@ -449,6 +432,22 @@ int __glXSwapReleaseTexImageEXT(__GLXclientState *cl, GLchar *pc)
|
|||
return __glXReleaseTexImageEXT(cl, (GLbyte *)pc);
|
||||
}
|
||||
|
||||
int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
|
||||
{
|
||||
xGLXVendorPrivateWithReplyReq *req = (xGLXVendorPrivateWithReplyReq *)pc;
|
||||
CARD32 *data;
|
||||
|
||||
__GLX_DECLARE_SWAP_VARIABLES;
|
||||
|
||||
data = (CARD32 *) (req + 1);
|
||||
__GLX_SWAP_SHORT(&req->length);
|
||||
__GLX_SWAP_INT(&req->contextTag);
|
||||
__GLX_SWAP_INT(data);
|
||||
|
||||
return __glXGetDrawableAttributesSGIX(cl, (GLbyte *)pc);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
|
|
@ -523,7 +522,8 @@ void __glXSwapQueryContextInfoEXTReply(ClientPtr client, xGLXQueryContextInfoEXT
|
|||
WriteToClient(client, length << 2, (char *)buf);
|
||||
}
|
||||
|
||||
void __glXSwapGetDrawableAttributesReply(ClientPtr client, xGLXGetDrawableAttributesReply *reply, int *buf)
|
||||
void __glXSwapGetDrawableAttributesReply(ClientPtr client,
|
||||
xGLXGetDrawableAttributesReply *reply, CARD32 *buf)
|
||||
{
|
||||
int length = reply->length;
|
||||
__GLX_DECLARE_SWAP_VARIABLES;
|
||||
|
|
@ -1124,8 +1124,8 @@ int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
|
|||
return __glXSwapCreateContextWithConfigSGIX(cl, pc);
|
||||
case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
|
||||
return __glXSwapCreateGLXPixmapWithConfigSGIX(cl, pc);
|
||||
case X_GLXvop_GetDrawableAttributesSGIX:
|
||||
return __glXGetDrawableAttributesSGIX(cl, pc);
|
||||
case X_GLXvop_GetDrawableAttributesSGIX:
|
||||
return __glXSwapGetDrawableAttributesSGIX(cl, pc);
|
||||
case X_GLvop_IsRenderbufferEXT:
|
||||
return __glXDispSwap_IsRenderbufferEXT(cl, pc);
|
||||
case X_GLvop_GenRenderbuffersEXT:
|
||||
|
|
|
|||
|
|
@ -41,32 +41,48 @@
|
|||
**
|
||||
*/
|
||||
|
||||
typedef struct __GLXcontextRec __GLXcontext;
|
||||
|
||||
/* XXX: should be defined somewhere globally */
|
||||
#define CAPI
|
||||
|
||||
#include "GL/internal/glcore.h"
|
||||
|
||||
struct __GLXcontextRec {
|
||||
typedef struct __GLXtextureFromPixmapContext __GLXtextureFromPixmapContext;
|
||||
struct __GLXtextureFromPixmapContext {
|
||||
int (*bindTexImage) (__GLXcontext *baseContext,
|
||||
int buffer,
|
||||
__GLXpixmap *pixmap);
|
||||
int (*releaseTexImage) (__GLXcontext *baseContext,
|
||||
int buffer,
|
||||
__GLXpixmap *pixmap);
|
||||
};
|
||||
|
||||
|
||||
struct __GLXcontext {
|
||||
void (*destroy) (__GLXcontext *context);
|
||||
int (*makeCurrent) (__GLXcontext *context);
|
||||
int (*loseCurrent) (__GLXcontext *context);
|
||||
int (*copy) (__GLXcontext *dst,
|
||||
__GLXcontext *src,
|
||||
unsigned long mask);
|
||||
int (*forceCurrent) (__GLXcontext *context);
|
||||
|
||||
__GLXdrawable *(*createDrawable)(__GLXcontext *context,
|
||||
DrawablePtr pDraw,
|
||||
XID drawId);
|
||||
|
||||
__GLXtextureFromPixmapContext *textureFromPixmap;
|
||||
|
||||
/*
|
||||
** list of context structs
|
||||
*/
|
||||
struct __GLXcontextRec *last;
|
||||
struct __GLXcontextRec *next;
|
||||
__GLXcontext *last;
|
||||
__GLXcontext *next;
|
||||
|
||||
/*
|
||||
** list of contexts bound to the same drawable
|
||||
*/
|
||||
struct __GLXcontextRec *nextDrawPriv;
|
||||
struct __GLXcontextRec *nextReadPriv;
|
||||
|
||||
/*
|
||||
** Opaque pointer the context object created by the GL that the
|
||||
** server is bound with. Never dereferenced by this code, but used
|
||||
** as a handle to feed to the routines in the screen info struct.
|
||||
*/
|
||||
__GLinterface *gc;
|
||||
__GLXcontext *nextDrawPriv;
|
||||
__GLXcontext *nextReadPriv;
|
||||
|
||||
/*
|
||||
** mode struct for this context
|
||||
|
|
@ -78,7 +94,7 @@ struct __GLXcontextRec {
|
|||
** when the context is created.
|
||||
*/
|
||||
ScreenPtr pScreen;
|
||||
__GLXscreenInfo *pGlxScreen;
|
||||
__GLXscreen *pGlxScreen;
|
||||
|
||||
/*
|
||||
** This context is created with respect to this visual.
|
||||
|
|
@ -152,8 +168,8 @@ struct __GLXcontextRec {
|
|||
/*
|
||||
** The drawable private this context is bound to
|
||||
*/
|
||||
__GLXdrawablePrivate *drawPriv;
|
||||
__GLXdrawablePrivate *readPriv;
|
||||
__GLXdrawable *drawPriv;
|
||||
__GLXdrawable *readPriv;
|
||||
};
|
||||
|
||||
/* pending state defines */
|
||||
|
|
|
|||
|
|
@ -45,20 +45,23 @@ typedef struct {
|
|||
|
||||
DrawablePtr pDraw;
|
||||
__GLcontextModes *modes;
|
||||
__GLXscreenInfo *pGlxScreen;
|
||||
__GLXscreen *pGlxScreen;
|
||||
ScreenPtr pScreen;
|
||||
Bool idExists;
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
int refcnt;
|
||||
|
||||
} __GLXpixmap;
|
||||
|
||||
struct __GLXdrawablePrivateRec {
|
||||
struct __GLXdrawable {
|
||||
void (*destroy)(__GLXdrawable *private);
|
||||
GLboolean (*resize)(__GLXdrawable *private);
|
||||
GLboolean (*swapBuffers)(__GLXdrawable *);
|
||||
|
||||
/*
|
||||
** list of drawable private structs
|
||||
*/
|
||||
struct __GLXdrawablePrivateRec *last;
|
||||
struct __GLXdrawablePrivateRec *next;
|
||||
__GLXdrawable *last;
|
||||
__GLXdrawable *next;
|
||||
|
||||
DrawablePtr pDraw;
|
||||
XID drawId;
|
||||
|
|
@ -76,40 +79,14 @@ struct __GLXdrawablePrivateRec {
|
|||
*/
|
||||
__GLcontextModes *modes;
|
||||
|
||||
/*
|
||||
** cached drawable size and origin
|
||||
*/
|
||||
|
||||
GLint xorigin, yorigin;
|
||||
GLint width, height;
|
||||
|
||||
/*
|
||||
** Lists of contexts bound to this drawable. There are two lists here.
|
||||
** One list is of the contexts that have this drawable bound for drawing,
|
||||
** and the other is the list of contexts that have this drawable bound
|
||||
** for reading.
|
||||
*/
|
||||
struct __GLXcontextRec *drawGlxc;
|
||||
struct __GLXcontextRec *readGlxc;
|
||||
|
||||
/*
|
||||
** "methods" that the drawble should be able to respond to.
|
||||
*/
|
||||
void (*freeBuffers)(struct __GLXdrawablePrivateRec *);
|
||||
void (*updatePalette)(struct __GLXdrawablePrivateRec *);
|
||||
GLboolean (*swapBuffers)(struct __GLXdrawablePrivateRec *);
|
||||
int (*bindBuffers)(struct __GLXdrawablePrivateRec *, int);
|
||||
int (*releaseBuffers)(struct __GLXdrawablePrivateRec *, int);
|
||||
|
||||
/*
|
||||
** Used by EXT_render_texture.
|
||||
*/
|
||||
GLenum texTarget;
|
||||
|
||||
/*
|
||||
** The GL drawable (information shared between GLX and the GL core)
|
||||
*/
|
||||
__GLdrawablePrivate glPriv;
|
||||
__GLXcontext *drawGlxc;
|
||||
__GLXcontext *readGlxc;
|
||||
|
||||
/*
|
||||
** reference count
|
||||
|
|
|
|||
937
GL/glx/glxdri.c
Normal file
937
GL/glx/glxdri.c
Normal file
|
|
@ -0,0 +1,937 @@
|
|||
/*
|
||||
* Copyright © 2006 Red Hat, Inc
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of Red Hat,
|
||||
* Inc not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL RED HAT, INC BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <drm.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/internal/dri_interface.h>
|
||||
|
||||
#include <windowstr.h>
|
||||
#include <os.h>
|
||||
|
||||
#define _XF86DRI_SERVER_
|
||||
#include <drm_sarea.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86dristr.h>
|
||||
#include <xf86str.h>
|
||||
#include <xf86.h>
|
||||
#include <dri.h>
|
||||
|
||||
#define DRI_NEW_INTERFACE_ONLY
|
||||
#include "glxserver.h"
|
||||
#include "glxutil.h"
|
||||
#include "glcontextmodes.h"
|
||||
|
||||
#include "g_disptab.h"
|
||||
#include "g_disptab_EXT.h"
|
||||
#include "glapitable.h"
|
||||
#include "glapi.h"
|
||||
#include "glthread.h"
|
||||
#include "dispatch.h"
|
||||
|
||||
|
||||
#define STRINGIFY(macro_or_string) STRINGIFY_ARG (macro_or_string)
|
||||
#define STRINGIFY_ARG(contents) #contents
|
||||
|
||||
typedef struct __GLXDRIscreen __GLXDRIscreen;
|
||||
typedef struct __GLXDRIcontext __GLXDRIcontext;
|
||||
typedef struct __GLXDRIdrawable __GLXDRIdrawable;
|
||||
|
||||
struct __GLXDRIscreen {
|
||||
__GLXscreen base;
|
||||
|
||||
__DRIscreen driScreen;
|
||||
void *driver;
|
||||
};
|
||||
|
||||
struct __GLXDRIcontext {
|
||||
__GLXcontext base;
|
||||
|
||||
__DRIcontext driContext;
|
||||
};
|
||||
|
||||
struct __GLXDRIdrawable {
|
||||
__GLXdrawable base;
|
||||
|
||||
__DRIdrawable *driDrawable;
|
||||
};
|
||||
|
||||
/* History:
|
||||
* 20021121 - Initial version
|
||||
* 20021128 - Added __glXWindowExists() function
|
||||
* 20021207 - Added support for dynamic GLX extensions,
|
||||
* GLX_SGI_swap_control, GLX_SGI_video_sync,
|
||||
* GLX_OML_sync_control, and GLX_MESA_swap_control.
|
||||
* Never officially released. Do NOT test against
|
||||
* this version. Use 20030317 instead.
|
||||
* 20030317 - Added support GLX_SGIX_fbconfig,
|
||||
* GLX_MESA_swap_frame_usage, GLX_OML_swap_method,
|
||||
* GLX_{ARB,SGIS}_multisample, and
|
||||
* GLX_SGIX_visual_select_group.
|
||||
* 20030606 - Added support for GLX_SGI_make_current_read.
|
||||
* 20030813 - Made support for dynamic extensions multi-head aware.
|
||||
* 20030818 - Added support for GLX_MESA_allocate_memory in place of the
|
||||
* deprecated GLX_NV_vertex_array_range & GLX_MESA_agp_offset
|
||||
* interfaces.
|
||||
* 20031201 - Added support for the first round of DRI interface changes.
|
||||
* Do NOT test against this version! It has binary
|
||||
* compatibility bugs, use 20040317 instead.
|
||||
* 20040317 - Added the 'mode' field to __DRIcontextRec.
|
||||
* 20040415 - Added support for bindContext3 and unbindContext3.
|
||||
* 20040602 - Add __glXGetDrawableInfo. I though that was there
|
||||
* months ago. :(
|
||||
* 20050727 - Gut all the old interfaces. This breaks compatability with
|
||||
* any DRI driver built to any previous version.
|
||||
*/
|
||||
#define INTERNAL_VERSION 20050727
|
||||
|
||||
static const char CREATE_NEW_SCREEN_FUNC[] =
|
||||
"__driCreateNewScreen_" STRINGIFY (INTERNAL_VERSION);
|
||||
|
||||
static void
|
||||
__glXDRIleaveServer(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
DRIDoBlockHandler(i, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
__glXDRIenterServer(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
DRIDoWakeupHandler(i, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
__glXDRIdrawableDestroy(__GLXdrawable *private)
|
||||
{
|
||||
#if 0
|
||||
(*glxPriv->driDrawable.destroyDrawable)(NULL,
|
||||
glxPriv->driDrawable.private);
|
||||
#endif
|
||||
|
||||
__glXFree(private);
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
__glXDRIdrawableResize(__GLXdrawable *glxPriv)
|
||||
{
|
||||
/* Nothing to do here, the DRI driver asks the server for drawable
|
||||
* geometry when it sess the SAREA timestamps change.*/
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
__glXDRIdrawableSwapBuffers(__GLXdrawable *basePrivate)
|
||||
{
|
||||
__GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate;
|
||||
__GLXDRIscreen *screen;
|
||||
|
||||
/* FIXME: We're jumping through hoops here to get the DRIdrawable
|
||||
* which the dri driver tries to keep to it self... cf. FIXME in
|
||||
* createDrawable. */
|
||||
|
||||
screen = (__GLXDRIscreen *) __glXgetActiveScreen(private->base.pDraw->pScreen->myNum);
|
||||
private->driDrawable = (screen->driScreen.getDrawable)(NULL,
|
||||
private->base.drawId,
|
||||
screen->driScreen.private);
|
||||
|
||||
(*private->driDrawable->swapBuffers)(NULL,
|
||||
private->driDrawable->private);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static __GLXdrawable *
|
||||
__glXDRIcontextCreateDrawable(__GLXcontext *context,
|
||||
DrawablePtr pDraw,
|
||||
XID drawId)
|
||||
{
|
||||
__GLXDRIdrawable *private;
|
||||
|
||||
private = __glXMalloc(sizeof *private);
|
||||
if (private == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(private, 0, sizeof *private);
|
||||
|
||||
if (!__glXDrawableInit(&private->base, context, pDraw, drawId)) {
|
||||
__glXFree(private);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private->base.destroy = __glXDRIdrawableDestroy;
|
||||
private->base.resize = __glXDRIdrawableResize;
|
||||
private->base.swapBuffers = __glXDRIdrawableSwapBuffers;
|
||||
|
||||
#if 0
|
||||
/* FIXME: It would only be natural that we called
|
||||
* driScreen->createNewDrawable here but the DRI drivers manage
|
||||
* them a little oddly. FIXME: describe this better.*/
|
||||
|
||||
/* The last argument is 'attrs', which is used with pbuffers which
|
||||
* we currently don't support. */
|
||||
|
||||
glxPriv->driDrawable.private =
|
||||
(pGlxScreen->driScreen.createNewDrawable)(NULL, modes,
|
||||
drawId,
|
||||
&glxPriv->driDrawable,
|
||||
0,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
return &private->base;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
__glXDRIcontextDestroy(__GLXcontext *baseContext)
|
||||
{
|
||||
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
||||
|
||||
context->driContext.destroyContext(NULL,
|
||||
context->base.pScreen->myNum,
|
||||
context->driContext.private);
|
||||
__glXFree(context);
|
||||
}
|
||||
|
||||
static int
|
||||
__glXDRIcontextMakeCurrent(__GLXcontext *baseContext)
|
||||
{
|
||||
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
||||
|
||||
return (*context->driContext.bindContext)(NULL,
|
||||
context->base.pScreen->myNum,
|
||||
baseContext->drawPriv->drawId,
|
||||
baseContext->readPriv->drawId,
|
||||
&context->driContext);
|
||||
}
|
||||
|
||||
static int
|
||||
__glXDRIcontextLoseCurrent(__GLXcontext *baseContext)
|
||||
{
|
||||
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
||||
|
||||
return (*context->driContext.unbindContext)(NULL,
|
||||
context->base.pScreen->myNum,
|
||||
baseContext->drawPriv->drawId,
|
||||
baseContext->readPriv->drawId,
|
||||
&context->driContext);
|
||||
}
|
||||
|
||||
static int
|
||||
__glXDRIcontextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc,
|
||||
unsigned long mask)
|
||||
{
|
||||
__GLXDRIcontext *dst = (__GLXDRIcontext *) baseDst;
|
||||
__GLXDRIcontext *src = (__GLXDRIcontext *) baseSrc;
|
||||
|
||||
/* FIXME: We will need to add DRIcontext::copyContext for this. */
|
||||
|
||||
(void) dst;
|
||||
(void) src;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
__glXDRIcontextForceCurrent(__GLXcontext *baseContext)
|
||||
{
|
||||
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
||||
|
||||
return (*context->driContext.bindContext)(NULL,
|
||||
context->base.pScreen->myNum,
|
||||
baseContext->drawPriv->drawId,
|
||||
baseContext->readPriv->drawId,
|
||||
&context->driContext);
|
||||
}
|
||||
|
||||
static int
|
||||
glxCountBits(int word)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while (word) {
|
||||
ret += (word & 1);
|
||||
word >>= 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
glxFillAlphaChannel (PixmapPtr pixmap)
|
||||
{
|
||||
int i, j;
|
||||
CARD32 *pixels = (CARD32 *)pixmap->devPrivate.ptr;
|
||||
CARD32 rowstride = pixmap->devKind / 4;
|
||||
CARD32 x, y;
|
||||
|
||||
x = pixmap->drawable.x;
|
||||
y = pixmap->drawable.y;
|
||||
|
||||
for (i = y; i < pixmap->drawable.height + y; ++i)
|
||||
{
|
||||
for (j = x; j < pixmap->drawable.width + x; ++j)
|
||||
{
|
||||
int index = i * rowstride + j;
|
||||
|
||||
pixels[index] |= 0xFF000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (sticking this here for lack of a better place)
|
||||
* Known issues with the GLX_EXT_texture_from_pixmap implementation:
|
||||
* - In general we ignore the fbconfig, lots of examples follow
|
||||
* - No fbconfig handling for multiple mipmap levels
|
||||
* - No fbconfig handling for 1D textures
|
||||
* - No fbconfig handling for TEXTURE_TARGET
|
||||
* - No fbconfig exposure of Y inversion state
|
||||
* - No GenerateMipmapEXT support (due to no FBO support)
|
||||
* - No damage tracking between binds
|
||||
* - No support for anything but 16bpp and 32bpp-sparse pixmaps
|
||||
*/
|
||||
|
||||
static int
|
||||
__glXDRIgetTexTarget (__GLXscreen *screen,
|
||||
__GLXpixmap *pixmap)
|
||||
{
|
||||
return GLX_TEXTURE_RECTANGLE_EXT;
|
||||
}
|
||||
|
||||
static __GLXtextureFromPixmapScreen __glXDRItextureFromPixmapScreen = {
|
||||
__glXDRIgetTexTarget,
|
||||
};
|
||||
|
||||
static int
|
||||
__glXDRIbindTexImage(__GLXcontext *baseContext,
|
||||
int buffer,
|
||||
__GLXpixmap *glxPixmap)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
int bpp;
|
||||
Bool npot;
|
||||
|
||||
pixmap = (PixmapPtr) glxPixmap->pDraw;
|
||||
bpp = pixmap->drawable.depth >= 24 ? 4 : 2; /* XXX 24bpp packed, 8, etc */
|
||||
|
||||
CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,
|
||||
pixmap->devKind / bpp) );
|
||||
CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS,
|
||||
pixmap->drawable.y) );
|
||||
CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS,
|
||||
pixmap->drawable.x) );
|
||||
|
||||
if (pixmap->drawable.depth == 24)
|
||||
glxFillAlphaChannel(pixmap);
|
||||
|
||||
npot = !(glxCountBits(pixmap->drawable.width) == 1 &&
|
||||
glxCountBits(pixmap->drawable.height) == 1) /* ||
|
||||
strstr(CALL_GetString(GL_EXTENSIONS,
|
||||
"GL_ARB_texture_non_power_of_two")) */ ;
|
||||
|
||||
CALL_TexImage2D( GET_DISPATCH(),
|
||||
( npot ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D,
|
||||
0,
|
||||
bpp == 4 ? 4 : 3,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
0,
|
||||
bpp == 4 ? GL_BGRA : GL_RGB,
|
||||
bpp == 4 ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
|
||||
pixmap->devPrivate.ptr ) );
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
__glXDRIreleaseTexImage(__GLXcontext *baseContext,
|
||||
int buffer,
|
||||
__GLXpixmap *pixmap)
|
||||
{
|
||||
return Success;
|
||||
}
|
||||
|
||||
static __GLXtextureFromPixmapContext __glXDRItextureFromPixmapContext = {
|
||||
__glXDRIbindTexImage,
|
||||
__glXDRIreleaseTexImage
|
||||
};
|
||||
|
||||
static void
|
||||
__glXDRIscreenDestroy(__GLXscreen *baseScreen)
|
||||
{
|
||||
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
|
||||
|
||||
screen->driScreen.destroyScreen(NULL,
|
||||
screen->base.pScreen->myNum,
|
||||
screen->driScreen.private);
|
||||
|
||||
dlclose(screen->driver);
|
||||
|
||||
__glXScreenDestroy(baseScreen);
|
||||
|
||||
__glXFree(screen);
|
||||
}
|
||||
|
||||
static __GLXcontext *
|
||||
__glXDRIscreenCreateContext(__GLXscreen *baseScreen,
|
||||
__GLcontextModes *modes,
|
||||
__GLXcontext *baseShareContext)
|
||||
{
|
||||
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
|
||||
__GLXDRIcontext *context, *shareContext;
|
||||
void *sharePrivate;
|
||||
|
||||
shareContext = (__GLXDRIcontext *) baseShareContext;
|
||||
if (shareContext)
|
||||
sharePrivate = shareContext->driContext.private;
|
||||
else
|
||||
sharePrivate = NULL;
|
||||
|
||||
context = __glXMalloc(sizeof *context);
|
||||
if (context == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(context, 0, sizeof *context);
|
||||
context->base.destroy = __glXDRIcontextDestroy;
|
||||
context->base.makeCurrent = __glXDRIcontextMakeCurrent;
|
||||
context->base.loseCurrent = __glXDRIcontextLoseCurrent;
|
||||
context->base.copy = __glXDRIcontextCopy;
|
||||
context->base.forceCurrent = __glXDRIcontextForceCurrent;
|
||||
context->base.createDrawable = __glXDRIcontextCreateDrawable;
|
||||
|
||||
context->base.textureFromPixmap = &__glXDRItextureFromPixmapContext;
|
||||
|
||||
context->driContext.private =
|
||||
screen->driScreen.createNewContext(NULL, modes,
|
||||
0, /* render type */
|
||||
sharePrivate,
|
||||
&context->driContext);
|
||||
|
||||
context->driContext.mode = modes;
|
||||
|
||||
return &context->base;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
filter_modes(__GLcontextModes **server_modes,
|
||||
const __GLcontextModes *driver_modes)
|
||||
{
|
||||
__GLcontextModes * m;
|
||||
__GLcontextModes ** prev_next;
|
||||
const __GLcontextModes * check;
|
||||
unsigned modes_count = 0;
|
||||
|
||||
if ( driver_modes == NULL ) {
|
||||
fprintf(stderr, "libGL warning: 3D driver returned no fbconfigs.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* For each mode in server_modes, check to see if a matching mode exists
|
||||
* in driver_modes. If not, then the mode is not available.
|
||||
*/
|
||||
|
||||
prev_next = server_modes;
|
||||
for ( m = *prev_next ; m != NULL ; m = *prev_next ) {
|
||||
GLboolean do_delete = GL_TRUE;
|
||||
|
||||
for ( check = driver_modes ; check != NULL ; check = check->next ) {
|
||||
if ( _gl_context_modes_are_same( m, check ) ) {
|
||||
do_delete = GL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* The 3D has to support all the modes that match the GLX visuals
|
||||
* sent from the X server.
|
||||
*/
|
||||
if ( do_delete && (m->visualID != 0) ) {
|
||||
do_delete = GL_FALSE;
|
||||
|
||||
fprintf(stderr, "libGL warning: 3D driver claims to not support "
|
||||
"visual 0x%02x\n", m->visualID);
|
||||
}
|
||||
|
||||
if ( do_delete ) {
|
||||
*prev_next = m->next;
|
||||
|
||||
m->next = NULL;
|
||||
_gl_context_modes_destroy( m );
|
||||
}
|
||||
else {
|
||||
modes_count++;
|
||||
prev_next = & m->next;
|
||||
}
|
||||
}
|
||||
|
||||
return modes_count;
|
||||
}
|
||||
|
||||
|
||||
static __DRIfuncPtr getProcAddress(const char *proc_name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static __DRIscreen *findScreen(__DRInativeDisplay *dpy, int scrn)
|
||||
{
|
||||
__GLXDRIscreen *screen =
|
||||
(__GLXDRIscreen *) __glXgetActiveScreen(scrn);
|
||||
|
||||
return &screen->driScreen;
|
||||
}
|
||||
|
||||
static GLboolean windowExists(__DRInativeDisplay *dpy, __DRIid draw)
|
||||
{
|
||||
WindowPtr pWin = (WindowPtr) LookupIDByType(draw, RT_WINDOW);
|
||||
|
||||
return pWin == NULL ? GL_FALSE : GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean createContext(__DRInativeDisplay *dpy, int screen,
|
||||
int configID, void *contextID,
|
||||
drm_context_t *hw_context)
|
||||
{
|
||||
XID fakeID;
|
||||
VisualPtr visual;
|
||||
int i;
|
||||
ScreenPtr pScreen;
|
||||
GLboolean retval;
|
||||
|
||||
pScreen = screenInfo.screens[screen];
|
||||
|
||||
/* Find the requested X visual */
|
||||
visual = pScreen->visuals;
|
||||
for (i = 0; i < pScreen->numVisuals; i++, visual++)
|
||||
if (visual->vid == configID)
|
||||
break;
|
||||
if (i == pScreen->numVisuals)
|
||||
return GL_FALSE;
|
||||
|
||||
fakeID = FakeClientID(0);
|
||||
*(XID *) contextID = fakeID;
|
||||
|
||||
__glXDRIenterServer();
|
||||
retval = DRICreateContext(pScreen, visual, fakeID, hw_context);
|
||||
__glXDRIleaveServer();
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GLboolean destroyContext(__DRInativeDisplay *dpy, int screen,
|
||||
__DRIid context)
|
||||
{
|
||||
GLboolean retval;
|
||||
|
||||
__glXDRIenterServer();
|
||||
retval = DRIDestroyContext(screenInfo.screens[screen], context);
|
||||
__glXDRIleaveServer();
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
createDrawable(__DRInativeDisplay *dpy, int screen,
|
||||
__DRIid drawable, drm_drawable_t *hHWDrawable)
|
||||
{
|
||||
DrawablePtr pDrawable;
|
||||
GLboolean retval;
|
||||
|
||||
pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE);
|
||||
if (!pDrawable)
|
||||
return GL_FALSE;
|
||||
|
||||
__glXDRIenterServer();
|
||||
retval = DRICreateDrawable(screenInfo.screens[screen],
|
||||
drawable,
|
||||
pDrawable,
|
||||
hHWDrawable);
|
||||
__glXDRIleaveServer();
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
destroyDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable)
|
||||
{
|
||||
DrawablePtr pDrawable;
|
||||
GLboolean retval;
|
||||
|
||||
pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE);
|
||||
if (!pDrawable)
|
||||
return GL_FALSE;
|
||||
|
||||
__glXDRIenterServer();
|
||||
retval = DRIDestroyDrawable(screenInfo.screens[screen],
|
||||
drawable,
|
||||
pDrawable);
|
||||
__glXDRIleaveServer();
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
getDrawableInfo(__DRInativeDisplay *dpy, int screen,
|
||||
__DRIid drawable, unsigned int *index, unsigned int *stamp,
|
||||
int *x, int *y, int *width, int *height,
|
||||
int *numClipRects, drm_clip_rect_t **ppClipRects,
|
||||
int *backX, int *backY,
|
||||
int *numBackClipRects, drm_clip_rect_t **ppBackClipRects)
|
||||
{
|
||||
DrawablePtr pDrawable;
|
||||
drm_clip_rect_t *pClipRects, *pBackClipRects;
|
||||
GLboolean retval;
|
||||
size_t size;
|
||||
|
||||
pDrawable = (DrawablePtr) LookupIDByClass(drawable, RC_DRAWABLE);
|
||||
if (!pDrawable) {
|
||||
ErrorF("getDrawableInfo failed to look up window\n");
|
||||
|
||||
*index = 0;
|
||||
*stamp = 0;
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*numClipRects = 0;
|
||||
*ppClipRects = NULL;
|
||||
*backX = 0;
|
||||
*backY = 0;
|
||||
*numBackClipRects = 0;
|
||||
*ppBackClipRects = NULL;
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
__glXDRIenterServer();
|
||||
retval = DRIGetDrawableInfo(screenInfo.screens[screen],
|
||||
pDrawable, index, stamp,
|
||||
x, y, width, height,
|
||||
numClipRects, &pClipRects,
|
||||
backX, backY,
|
||||
numBackClipRects, &pBackClipRects);
|
||||
__glXDRIleaveServer();
|
||||
|
||||
if (*numClipRects > 0) {
|
||||
size = sizeof (drm_clip_rect_t) * *numClipRects;
|
||||
*ppClipRects = __glXMalloc (size);
|
||||
if (*ppClipRects != NULL)
|
||||
memcpy (*ppClipRects, pClipRects, size);
|
||||
}
|
||||
else {
|
||||
*ppClipRects = NULL;
|
||||
}
|
||||
|
||||
if (*numBackClipRects > 0) {
|
||||
size = sizeof (drm_clip_rect_t) * *numBackClipRects;
|
||||
*ppBackClipRects = __glXMalloc (size);
|
||||
if (*ppBackClipRects != NULL)
|
||||
memcpy (*ppBackClipRects, pBackClipRects, size);
|
||||
}
|
||||
else {
|
||||
*ppBackClipRects = NULL;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
getUST(int64_t *ust)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (ust == NULL)
|
||||
return -EFAULT;
|
||||
|
||||
if (gettimeofday(&tv, NULL) == 0) {
|
||||
ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
return 0;
|
||||
} else {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
/* Table of functions that we export to the driver. */
|
||||
static const __DRIinterfaceMethods interface_methods = {
|
||||
getProcAddress,
|
||||
|
||||
_gl_context_modes_create,
|
||||
_gl_context_modes_destroy,
|
||||
|
||||
findScreen,
|
||||
windowExists,
|
||||
|
||||
createContext,
|
||||
destroyContext,
|
||||
|
||||
createDrawable,
|
||||
destroyDrawable,
|
||||
getDrawableInfo,
|
||||
|
||||
getUST,
|
||||
NULL, /* glXGetMscRateOML, */
|
||||
};
|
||||
|
||||
static const char dri_driver_path[] = DRI_DRIVER_PATH;
|
||||
|
||||
static __GLXscreen *
|
||||
__glXDRIscreenProbe(ScreenPtr pScreen)
|
||||
{
|
||||
PFNCREATENEWSCREENFUNC createNewScreen;
|
||||
drm_handle_t hSAREA;
|
||||
drmAddress pSAREA = NULL;
|
||||
char *BusID;
|
||||
__DRIversion ddx_version;
|
||||
__DRIversion dri_version;
|
||||
__DRIversion drm_version;
|
||||
__DRIframebuffer framebuffer;
|
||||
int fd = -1;
|
||||
int status;
|
||||
const char *err_msg;
|
||||
const char *err_extra = NULL;
|
||||
int api_ver = INTERNAL_VERSION;
|
||||
drm_magic_t magic;
|
||||
drmVersionPtr version;
|
||||
char *driverName;
|
||||
drm_handle_t hFB;
|
||||
int junk;
|
||||
__GLcontextModes * driver_modes;
|
||||
__GLXDRIscreen *screen;
|
||||
void *dev_priv = NULL;
|
||||
char filename[128];
|
||||
|
||||
screen = __glXMalloc(sizeof *screen);
|
||||
if (screen == NULL)
|
||||
return NULL;
|
||||
memset(screen, 0, sizeof *screen);
|
||||
|
||||
screen->base.destroy = __glXDRIscreenDestroy;
|
||||
screen->base.createContext = __glXDRIscreenCreateContext;
|
||||
screen->base.pScreen = pScreen;
|
||||
|
||||
screen->base.textureFromPixmap = __glXDRItextureFromPixmapScreen;
|
||||
|
||||
/* DRI protocol version. */
|
||||
dri_version.major = XF86DRI_MAJOR_VERSION;
|
||||
dri_version.minor = XF86DRI_MINOR_VERSION;
|
||||
dri_version.patch = XF86DRI_PATCH_VERSION;
|
||||
|
||||
framebuffer.base = NULL;
|
||||
framebuffer.dev_priv = NULL;
|
||||
|
||||
if (!DRIOpenConnection(pScreen, &hSAREA, &BusID)) {
|
||||
err_msg = "DRIOpenConnection";
|
||||
err_extra = NULL;
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
fd = drmOpen(NULL, BusID);
|
||||
|
||||
if (fd < 0) {
|
||||
err_msg = "open DRM";
|
||||
err_extra = strerror( -fd );
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
if (drmGetMagic(fd, &magic)) {
|
||||
err_msg = "drmGetMagic";
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
version = drmGetVersion(fd);
|
||||
if (version) {
|
||||
drm_version.major = version->version_major;
|
||||
drm_version.minor = version->version_minor;
|
||||
drm_version.patch = version->version_patchlevel;
|
||||
drmFreeVersion(version);
|
||||
}
|
||||
else {
|
||||
drm_version.major = -1;
|
||||
drm_version.minor = -1;
|
||||
drm_version.patch = -1;
|
||||
}
|
||||
|
||||
if (!DRIAuthConnection(pScreen, magic)) {
|
||||
err_msg = "DRIAuthConnection";
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
/* Get device name (like "tdfx") and the ddx version numbers.
|
||||
* We'll check the version in each DRI driver's "createNewScreen"
|
||||
* function. */
|
||||
if (!DRIGetClientDriverName(pScreen,
|
||||
&ddx_version.major,
|
||||
&ddx_version.minor,
|
||||
&ddx_version.patch,
|
||||
&driverName)) {
|
||||
err_msg = "DRIGetClientDriverName";
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
snprintf(filename, sizeof filename, "%s/%s_dri.so",
|
||||
dri_driver_path, driverName);
|
||||
|
||||
screen->driver = dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
|
||||
if (screen->driver == NULL) {
|
||||
err_msg = "Loading driver";
|
||||
err_extra = filename;
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
createNewScreen = dlsym(screen->driver, CREATE_NEW_SCREEN_FUNC);
|
||||
if (createNewScreen == NULL) {
|
||||
err_msg = "Driver entry point lookup";
|
||||
err_extra = CREATE_NEW_SCREEN_FUNC;
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get device-specific info. pDevPriv will point to a struct
|
||||
* (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h) that
|
||||
* has information about the screen size, depth, pitch, ancilliary
|
||||
* buffers, DRM mmap handles, etc.
|
||||
*/
|
||||
if (!DRIGetDeviceInfo(pScreen, &hFB, &junk,
|
||||
&framebuffer.size, &framebuffer.stride,
|
||||
&framebuffer.dev_priv_size, &framebuffer.dev_priv)) {
|
||||
err_msg = "XF86DRIGetDeviceInfo";
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
/* Sigh... the DRI interface is broken; the DRI driver will free
|
||||
* the dev private pointer using _mesa_free() on screen destroy,
|
||||
* but we can't use _mesa_malloc() here. In fact, the DRI driver
|
||||
* shouldn't free data it didn't allocate itself, but what can you
|
||||
* do... */
|
||||
dev_priv = __glXMalloc(framebuffer.dev_priv_size);
|
||||
if (dev_priv == NULL) {
|
||||
err_msg = "dev_priv allocation";
|
||||
goto handle_error;
|
||||
}
|
||||
memcpy(dev_priv, framebuffer.dev_priv, framebuffer.dev_priv_size);
|
||||
framebuffer.dev_priv = dev_priv;
|
||||
|
||||
framebuffer.width = pScreen->width;
|
||||
framebuffer.height = pScreen->height;
|
||||
|
||||
/* Map the framebuffer region. */
|
||||
status = drmMap(fd, hFB, framebuffer.size,
|
||||
(drmAddressPtr)&framebuffer.base);
|
||||
if (status != 0) {
|
||||
err_msg = "drmMap of framebuffer";
|
||||
err_extra = strerror( -status );
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
/* Map the SAREA region. Further mmap regions may be setup in
|
||||
* each DRI driver's "createNewScreen" function.
|
||||
*/
|
||||
status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA);
|
||||
if (status != 0) {
|
||||
err_msg = "drmMap of sarea";
|
||||
err_extra = strerror( -status );
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
__glXScreenInit(&screen->base, pScreen);
|
||||
|
||||
driver_modes = NULL;
|
||||
screen->driScreen.private =
|
||||
(*createNewScreen)(NULL, pScreen->myNum,
|
||||
&screen->driScreen,
|
||||
screen->base.modes,
|
||||
&ddx_version,
|
||||
&dri_version,
|
||||
&drm_version,
|
||||
&framebuffer,
|
||||
pSAREA,
|
||||
fd,
|
||||
api_ver,
|
||||
&interface_methods,
|
||||
&driver_modes);
|
||||
|
||||
if (screen->driScreen.private == NULL) {
|
||||
err_msg = "InitDriver";
|
||||
err_extra = NULL;
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
filter_modes(&screen->base.modes, driver_modes);
|
||||
_gl_context_modes_destroy(driver_modes);
|
||||
|
||||
__glXsetEnterLeaveServerFuncs(__glXDRIenterServer, __glXDRIleaveServer);
|
||||
|
||||
LogMessage(X_INFO,
|
||||
"GLX-DRI: Loaded and initialized %s\n", filename);
|
||||
|
||||
return &screen->base;
|
||||
|
||||
handle_error:
|
||||
if (pSAREA != NULL)
|
||||
drmUnmap(pSAREA, SAREA_MAX);
|
||||
|
||||
if (framebuffer.base != NULL)
|
||||
drmUnmap((drmAddress)framebuffer.base, framebuffer.size);
|
||||
|
||||
if (dev_priv != NULL)
|
||||
__glXFree(dev_priv);
|
||||
|
||||
if (fd >= 0)
|
||||
drmClose(fd);
|
||||
|
||||
DRICloseConnection(pScreen);
|
||||
|
||||
if (screen->driver)
|
||||
dlclose(screen->driver);
|
||||
|
||||
xfree(screen);
|
||||
|
||||
if (err_extra != NULL)
|
||||
LogMessage(X_ERROR,
|
||||
"GLX-DRI error: %s failed (%s)\n", err_msg, err_extra);
|
||||
else
|
||||
LogMessage(X_ERROR, "GLX-DRI error: %s failed\n", err_msg);
|
||||
|
||||
ErrorF("GLX-DRI: reverting to software rendering\n");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__GLXprovider __glXDRIProvider = {
|
||||
__glXDRIscreenProbe,
|
||||
"DRI",
|
||||
NULL
|
||||
};
|
||||
213
GL/glx/glxext.c
213
GL/glx/glxext.c
|
|
@ -23,6 +23,7 @@
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "glxserver.h"
|
||||
#include <windowstr.h>
|
||||
#include <propertyst.h>
|
||||
|
|
@ -31,19 +32,12 @@
|
|||
#include "unpack.h"
|
||||
#include "glxutil.h"
|
||||
#include "glxext.h"
|
||||
#include "micmap.h"
|
||||
|
||||
|
||||
void GlxWrapInitVisuals(miInitVisualsProcPtr *);
|
||||
void GlxSetVisualConfigs(int nconfigs,
|
||||
__GLXvisualConfig *configs, void **privates);
|
||||
|
||||
static __GLXextensionInfo *__glXExt /* = &__glDDXExtensionInfo */;
|
||||
static Bool inDispatch;
|
||||
|
||||
/*
|
||||
** Forward declarations.
|
||||
*/
|
||||
static int __glXSwapDispatch(ClientPtr);
|
||||
static int __glXDispatch(ClientPtr);
|
||||
|
||||
/*
|
||||
|
|
@ -52,8 +46,7 @@ static int __glXDispatch(ClientPtr);
|
|||
static void ResetExtension(ExtensionEntry* extEntry)
|
||||
{
|
||||
__glXFlushContextCache();
|
||||
(*__glXExt->resetExtension)();
|
||||
__glXScreenReset();
|
||||
__glXResetScreens();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -158,6 +151,40 @@ static int PixmapGone(__GLXpixmap *pGlxPixmap, XID id)
|
|||
return True;
|
||||
}
|
||||
|
||||
/*
|
||||
** Destroy routine that gets called when a drawable is freed. A drawable
|
||||
** contains the ancillary buffers needed for rendering.
|
||||
*/
|
||||
static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid)
|
||||
{
|
||||
__GLXcontext *cx, *cx1;
|
||||
|
||||
/*
|
||||
** Use glxPriv->type to figure out what kind of drawable this is. Don't
|
||||
** use glxPriv->pDraw->type because by the time this routine is called,
|
||||
** the pDraw might already have been freed.
|
||||
*/
|
||||
if (glxPriv->type == DRAWABLE_WINDOW) {
|
||||
/*
|
||||
** When a window is destroyed, notify all context bound to
|
||||
** it, that there are no longer bound to anything.
|
||||
*/
|
||||
for (cx = glxPriv->drawGlxc; cx; cx = cx1) {
|
||||
cx1 = cx->nextDrawPriv;
|
||||
cx->pendingState |= __GLX_PENDING_DESTROY;
|
||||
}
|
||||
|
||||
for (cx = glxPriv->readGlxc; cx; cx = cx1) {
|
||||
cx1 = cx->nextReadPriv;
|
||||
cx->pendingState |= __GLX_PENDING_DESTROY;
|
||||
}
|
||||
}
|
||||
|
||||
__glXUnrefDrawable(glxPriv);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*
|
||||
** Free a context.
|
||||
*/
|
||||
|
|
@ -165,18 +192,24 @@ GLboolean __glXFreeContext(__GLXcontext *cx)
|
|||
{
|
||||
if (cx->idExists || cx->isCurrent) return GL_FALSE;
|
||||
|
||||
if (!cx->isDirect) {
|
||||
if ((*cx->gc->exports.destroyContext)((__GLcontext *)cx->gc) == GL_FALSE) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
if (cx->feedbackBuf) __glXFree(cx->feedbackBuf);
|
||||
if (cx->selectBuf) __glXFree(cx->selectBuf);
|
||||
__glXFree(cx);
|
||||
if (cx == __glXLastContext) {
|
||||
__glXFlushContextCache();
|
||||
}
|
||||
|
||||
/* We can get here through both regular dispatching from
|
||||
* __glXDispatch() or as a callback from the resource manager. In
|
||||
* the latter case we need to lift the DRI lock manually. */
|
||||
|
||||
if (!inDispatch)
|
||||
__glXleaveServer();
|
||||
|
||||
cx->destroy(cx);
|
||||
|
||||
if (!inDispatch)
|
||||
__glXenterServer();
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -240,13 +273,14 @@ void GlxExtensionInit(void)
|
|||
__glXContextRes = CreateNewResourceType((DeleteType)ContextGone);
|
||||
__glXClientRes = CreateNewResourceType((DeleteType)ClientGone);
|
||||
__glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone);
|
||||
__glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
|
||||
|
||||
/*
|
||||
** Add extension to server extensions.
|
||||
*/
|
||||
extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
|
||||
__GLX_NUMBER_ERRORS, __glXDispatch,
|
||||
__glXSwapDispatch, ResetExtension,
|
||||
__glXDispatch, ResetExtension,
|
||||
StandardMinorOpcode);
|
||||
if (!extEntry) {
|
||||
FatalError("__glXExtensionInit: AddExtensions failed\n");
|
||||
|
|
@ -280,53 +314,7 @@ void GlxExtensionInit(void)
|
|||
/*
|
||||
** Initialize screen specific data.
|
||||
*/
|
||||
__glXScreenInit(screenInfo.numScreens);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
Bool __glXCoreType(void)
|
||||
{
|
||||
return __glXExt->type;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
void GlxSetVisualConfigs(int nconfigs,
|
||||
__GLXvisualConfig *configs, void **privates)
|
||||
{
|
||||
(*__glXExt->setVisualConfigs)(nconfigs, configs, privates);
|
||||
}
|
||||
|
||||
static miInitVisualsProcPtr saveInitVisualsProc;
|
||||
|
||||
Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
|
||||
int *nvisualp, int *ndepthp,
|
||||
int *rootDepthp, VisualID *defaultVisp,
|
||||
unsigned long sizes, int bitsPerRGB,
|
||||
int preferredVis)
|
||||
{
|
||||
Bool ret;
|
||||
|
||||
if (saveInitVisualsProc) {
|
||||
ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
|
||||
rootDepthp, defaultVisp, sizes, bitsPerRGB,
|
||||
preferredVis);
|
||||
if (!ret)
|
||||
return False;
|
||||
}
|
||||
(*__glXExt->initVisuals)(visualp, depthp, nvisualp, ndepthp, rootDepthp,
|
||||
defaultVisp, sizes, bitsPerRGB);
|
||||
return True;
|
||||
}
|
||||
|
||||
void
|
||||
GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
|
||||
{
|
||||
saveInitVisualsProc = *initVisProc;
|
||||
*initVisProc = GlxInitVisuals;
|
||||
/* HACK: this shouldn't be done here but it's the earliest time */
|
||||
__glXExt = __glXglDDXExtensionInfo(); /* from GLcore */
|
||||
__glXInitScreens();
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
|
@ -377,7 +365,7 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
|
|||
|
||||
/* Make this context the current one for the GL. */
|
||||
if (!cx->isDirect) {
|
||||
if (!(*cx->gc->exports.forceCurrent)((__GLcontext *)cx->gc)) {
|
||||
if (!(*cx->forceCurrent)(cx)) {
|
||||
/* Bind failed, and set the error code. Bummer */
|
||||
cl->client->errorValue = cx->id;
|
||||
*error = __glXBadContextState;
|
||||
|
|
@ -390,6 +378,44 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag,
|
|||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
** Top level dispatcher; all commands are executed from here down.
|
||||
*/
|
||||
|
||||
/* I cried when I wrote this. Damn you XAA! */
|
||||
|
||||
static void
|
||||
__glXnopEnterServer(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
__glXnopLeaveServer(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void (*__glXenterServerFunc)(void) = __glXnopEnterServer;
|
||||
static void (*__glXleaveServerFunc)(void) = __glXnopLeaveServer;
|
||||
|
||||
void __glXsetEnterLeaveServerFuncs(void (*enter)(void),
|
||||
void (*leave)(void))
|
||||
{
|
||||
__glXenterServerFunc = enter;
|
||||
__glXleaveServerFunc = leave;
|
||||
}
|
||||
|
||||
|
||||
void __glXenterServer(void)
|
||||
{
|
||||
(*__glXenterServerFunc)();
|
||||
}
|
||||
|
||||
void __glXleaveServer(void)
|
||||
{
|
||||
(*__glXleaveServerFunc)();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Top level dispatcher; all commands are executed from here down.
|
||||
*/
|
||||
|
|
@ -399,6 +425,7 @@ static int __glXDispatch(ClientPtr client)
|
|||
CARD8 opcode;
|
||||
int (*proc)(__GLXclientState *cl, GLbyte *pc);
|
||||
__GLXclientState *cl;
|
||||
int retval;
|
||||
|
||||
opcode = stuff->glxCode;
|
||||
cl = __glXClients[client->index];
|
||||
|
|
@ -443,54 +470,22 @@ static int __glXDispatch(ClientPtr client)
|
|||
/*
|
||||
** Use the opcode to index into the procedure table.
|
||||
*/
|
||||
proc = __glXSingleTable[opcode];
|
||||
return (*proc)(cl, (GLbyte *) stuff);
|
||||
}
|
||||
if (client->swapped)
|
||||
proc = __glXSwapSingleTable[opcode];
|
||||
else
|
||||
proc = __glXSingleTable[opcode];
|
||||
|
||||
static int __glXSwapDispatch(ClientPtr client)
|
||||
{
|
||||
REQUEST(xGLXSingleReq);
|
||||
CARD8 opcode;
|
||||
int (*proc)(__GLXclientState *cl, GLbyte *pc);
|
||||
__GLXclientState *cl;
|
||||
__glXleaveServer();
|
||||
|
||||
opcode = stuff->glxCode;
|
||||
cl = __glXClients[client->index];
|
||||
if (!cl) {
|
||||
cl = (__GLXclientState *) __glXMalloc(sizeof(__GLXclientState));
|
||||
__glXClients[client->index] = cl;
|
||||
if (!cl) {
|
||||
return BadAlloc;
|
||||
}
|
||||
__glXMemset(cl, 0, sizeof(__GLXclientState));
|
||||
}
|
||||
|
||||
if (!cl->inUse) {
|
||||
/*
|
||||
** This is first request from this client. Associate a resource
|
||||
** with the client so we will be notified when the client dies.
|
||||
*/
|
||||
XID xid = FakeClientID(client->index);
|
||||
if (!AddResource( xid, __glXClientRes, (pointer)(long)client->index)) {
|
||||
return BadAlloc;
|
||||
}
|
||||
ResetClientState(client->index);
|
||||
cl->inUse = GL_TRUE;
|
||||
cl->client = client;
|
||||
}
|
||||
inDispatch = True;
|
||||
|
||||
/*
|
||||
** Check for valid opcode.
|
||||
*/
|
||||
if (opcode >= __GLX_SINGLE_TABLE_SIZE) {
|
||||
return BadRequest;
|
||||
}
|
||||
retval = proc(cl, (GLbyte *) stuff);
|
||||
|
||||
/*
|
||||
** Use the opcode to index into the procedure table.
|
||||
*/
|
||||
proc = __glXSwapSingleTable[opcode];
|
||||
return (*proc)(cl, (GLbyte *) stuff);
|
||||
inDispatch = False;
|
||||
|
||||
__glXenterServer();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int __glXNoSuchSingleOpcode(__GLXclientState *cl, GLbyte *pc)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glxserver.h"
|
||||
#include "glxcontext.h"
|
||||
#include "glximports.h"
|
||||
|
|
|
|||
|
|
@ -38,14 +38,9 @@
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifdef IN_MODULE
|
||||
#include <xf86_ansic.h>
|
||||
#else
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#include <windowstr.h>
|
||||
#include <os.h>
|
||||
|
||||
#include "glxserver.h"
|
||||
#include "glxutil.h"
|
||||
|
|
@ -135,6 +130,7 @@ static char GLXServerExtensions[] =
|
|||
"GLX_EXT_visual_info "
|
||||
"GLX_EXT_visual_rating "
|
||||
"GLX_EXT_import_context "
|
||||
"GLX_EXT_texture_from_pixmap "
|
||||
"GLX_OML_swap_method "
|
||||
"GLX_SGI_make_current_read "
|
||||
#ifndef __DARWIN__
|
||||
|
|
@ -143,78 +139,19 @@ static char GLXServerExtensions[] =
|
|||
"GLX_SGIX_swap_barrier "
|
||||
#endif
|
||||
"GLX_SGIX_fbconfig "
|
||||
"GLX_EXT_texture_from_pixmap "
|
||||
;
|
||||
|
||||
/*
|
||||
* __glDDXScreenInfo comes from GLcore, so we can't resolve this symbol at
|
||||
* module open time. Leave a placeholder, and fill this in when we first
|
||||
* need it (in __glXScreenInit). XXX Why make this an array?
|
||||
*/
|
||||
static __GLXscreenInfo *__glXScreens[] = {
|
||||
NULL /* &__glDDXScreenInfo */ ,
|
||||
};
|
||||
|
||||
static GLint __glXNumStaticScreens =
|
||||
(sizeof __glXScreens / sizeof __glXScreens[0]);
|
||||
|
||||
__GLXscreenInfo *__glXActiveScreens;
|
||||
GLint __glXNumActiveScreens;
|
||||
__GLXscreen **__glXActiveScreens;
|
||||
|
||||
__GLXSwapBarrierExtensionFuncs *__glXSwapBarrierFuncs = NULL;
|
||||
static int __glXNumSwapBarrierFuncs = 0;
|
||||
__GLXHyperpipeExtensionFuncs *__glXHyperpipeFuncs = NULL;
|
||||
static int __glXNumHyperpipeFuncs = 0;
|
||||
|
||||
|
||||
RESTYPE __glXDrawableRes;
|
||||
|
||||
__GLXscreenInfo *__glXgetActiveScreen(int num) {
|
||||
return &__glXActiveScreens[num];
|
||||
__GLXscreen *__glXgetActiveScreen(int num) {
|
||||
return __glXActiveScreens[num];
|
||||
}
|
||||
|
||||
/*
|
||||
** Destroy routine that gets called when a drawable is freed. A drawable
|
||||
** contains the ancillary buffers needed for rendering.
|
||||
*/
|
||||
static Bool DrawableGone(__GLXdrawablePrivate *glxPriv, XID xid)
|
||||
{
|
||||
__GLXcontext *cx, *cx1;
|
||||
|
||||
/*
|
||||
** Use glxPriv->type to figure out what kind of drawable this is. Don't
|
||||
** use glxPriv->pDraw->type because by the time this routine is called,
|
||||
** the pDraw might already have been freed.
|
||||
*/
|
||||
if (glxPriv->type == DRAWABLE_WINDOW) {
|
||||
/*
|
||||
** When a window is destroyed, notify all context bound to
|
||||
** it, that there are no longer bound to anything.
|
||||
*/
|
||||
for (cx = glxPriv->drawGlxc; cx; cx = cx1) {
|
||||
cx1 = cx->nextDrawPriv;
|
||||
cx->pendingState |= __GLX_PENDING_DESTROY;
|
||||
}
|
||||
|
||||
for (cx = glxPriv->readGlxc; cx; cx = cx1) {
|
||||
cx1 = cx->nextReadPriv;
|
||||
cx->pendingState |= __GLX_PENDING_DESTROY;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** set the size to 0, so that context that may still be using this
|
||||
** drawable not do anything harmful
|
||||
*/
|
||||
glxPriv->xorigin = 0;
|
||||
glxPriv->yorigin = 0;
|
||||
glxPriv->width = 0;
|
||||
glxPriv->height = 0;
|
||||
|
||||
__glXUnrefDrawablePrivate(glxPriv);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*
|
||||
** This hook gets called when a window moves or changes size.
|
||||
|
|
@ -223,7 +160,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
|
|||
{
|
||||
ScreenPtr pScreen;
|
||||
__GLXcontext *glxc;
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
__GLXdrawable *glxPriv;
|
||||
Bool ret;
|
||||
|
||||
/*
|
||||
|
|
@ -231,7 +168,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
|
|||
*/
|
||||
pScreen = pWin->drawable.pScreen;
|
||||
pScreen->PositionWindow =
|
||||
__glXActiveScreens[pScreen->myNum].WrappedPositionWindow;
|
||||
__glXActiveScreens[pScreen->myNum]->WrappedPositionWindow;
|
||||
ret = (*pScreen->PositionWindow)(pWin, x, y);
|
||||
pScreen->PositionWindow = PositionWindow;
|
||||
|
||||
|
|
@ -239,8 +176,8 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
|
|||
** Tell all contexts rendering into this window that the window size
|
||||
** has changed.
|
||||
*/
|
||||
glxPriv = (__GLXdrawablePrivate *) LookupIDByType(pWin->drawable.id,
|
||||
__glXDrawableRes);
|
||||
glxPriv = (__GLXdrawable *) LookupIDByType(pWin->drawable.id,
|
||||
__glXDrawableRes);
|
||||
if (glxPriv == NULL) {
|
||||
/*
|
||||
** This window is not being used by the OpenGL.
|
||||
|
|
@ -252,7 +189,7 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
|
|||
** resize the drawable
|
||||
*/
|
||||
/* first change the drawable size */
|
||||
if (__glXResizeDrawableBuffers(glxPriv) == GL_FALSE) {
|
||||
if (glxPriv->resize(glxPriv) == GL_FALSE) {
|
||||
/* resize failed! */
|
||||
/* XXX: what can we possibly do here? */
|
||||
ret = False;
|
||||
|
|
@ -271,18 +208,6 @@ static Bool PositionWindow(WindowPtr pWin, int x, int y)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
** Wrap our own PositionWindow routine around the server's, so we can
|
||||
** be notified when a window changes size
|
||||
*/
|
||||
static void wrapPositionWindow(int screen)
|
||||
{
|
||||
ScreenPtr pScreen = screenInfo.screens[screen];
|
||||
|
||||
__glXActiveScreens[screen].WrappedPositionWindow = pScreen->PositionWindow;
|
||||
pScreen->PositionWindow = PositionWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
* If your DDX driver wants to register support for swap barriers or hyperpipe
|
||||
* topology, it should call __glXHyperpipeInit() or __glXSwapBarrierInit()
|
||||
|
|
@ -326,57 +251,80 @@ void __glXSwapBarrierInit(int screen, __GLXSwapBarrierExtensionFuncs *funcs)
|
|||
funcs->queryMaxSwapBarriersFunc;
|
||||
}
|
||||
|
||||
void __glXScreenInit(GLint numscreens)
|
||||
{
|
||||
GLint i,j;
|
||||
static __GLXprovider *__glXProviderStack;
|
||||
|
||||
__glXScreens[0] = __glXglDDXScreenInfo(); /* from GLcore */
|
||||
void GlxPushProvider(__GLXprovider *provider)
|
||||
{
|
||||
provider->next = __glXProviderStack;
|
||||
__glXProviderStack = provider;
|
||||
}
|
||||
|
||||
void __glXScreenInit(__GLXscreen *screen, ScreenPtr pScreen)
|
||||
{
|
||||
screen->pScreen = pScreen;
|
||||
screen->GLextensions = __glXStrdup(GLServerExtensions);
|
||||
screen->GLXvendor = __glXStrdup(GLXServerVendorName);
|
||||
screen->GLXversion = __glXStrdup(GLXServerVersion);
|
||||
screen->GLXextensions = __glXStrdup(GLXServerExtensions);
|
||||
|
||||
screen->WrappedPositionWindow = pScreen->PositionWindow;
|
||||
pScreen->PositionWindow = PositionWindow;
|
||||
|
||||
__glXScreenInitVisuals(screen);
|
||||
}
|
||||
|
||||
void
|
||||
__glXScreenDestroy(__GLXscreen *screen)
|
||||
{
|
||||
__glXFree(screen->GLXvendor);
|
||||
__glXFree(screen->GLXversion);
|
||||
__glXFree(screen->GLXextensions);
|
||||
__glXFree(screen->GLextensions);
|
||||
}
|
||||
|
||||
void __glXInitScreens(void)
|
||||
{
|
||||
GLint i;
|
||||
ScreenPtr pScreen;
|
||||
__GLXprovider *p;
|
||||
size_t size;
|
||||
|
||||
/*
|
||||
** This alloc has to work or else the server might as well core dump.
|
||||
*/
|
||||
__glXActiveScreens =
|
||||
(__GLXscreenInfo *) __glXMalloc(sizeof(__GLXscreenInfo) * numscreens);
|
||||
size = screenInfo.numScreens * sizeof(__GLXscreen *);
|
||||
__glXActiveScreens =__glXMalloc(size);
|
||||
__glXMemset(__glXActiveScreens, 0, size);
|
||||
|
||||
for (i=0; i < numscreens; i++) {
|
||||
/*
|
||||
** Probe each static screen to see which exists.
|
||||
*/
|
||||
for (j=0; j < __glXNumStaticScreens; j++) {
|
||||
if ((*__glXScreens[j]->screenProbe)(i)) {
|
||||
__glXActiveScreens[i] = *__glXScreens[j];
|
||||
for (i = 0; i < screenInfo.numScreens; i++) {
|
||||
pScreen = screenInfo.screens[i];
|
||||
|
||||
__glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals;
|
||||
__glXActiveScreens[i].GLextensions = __glXStrdup(GLServerExtensions);
|
||||
__glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName);
|
||||
__glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion);
|
||||
__glXActiveScreens[i].GLXextensions = __glXStrdup(GLXServerExtensions);
|
||||
|
||||
__glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone);
|
||||
wrapPositionWindow(i);
|
||||
for (p = __glXProviderStack; p != NULL; p = p->next) {
|
||||
__glXActiveScreens[i] = p->screenProbe(pScreen);
|
||||
if (__glXActiveScreens[i] != NULL) {
|
||||
LogMessage(X_INFO,
|
||||
"GLX: Initialized %s GL provider for screen %d\n",
|
||||
p->name, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
__glXNumActiveScreens = numscreens;
|
||||
}
|
||||
|
||||
void __glXScreenReset(void)
|
||||
void __glXResetScreens(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < __glXNumActiveScreens; i++) {
|
||||
__glXFree(__glXActiveScreens[i].GLXvendor);
|
||||
__glXFree(__glXActiveScreens[i].GLXversion);
|
||||
__glXFree(__glXActiveScreens[i].GLXextensions);
|
||||
__glXFree(__glXActiveScreens[i].GLextensions);
|
||||
}
|
||||
xfree(__glXActiveScreens);
|
||||
xfree(__glXHyperpipeFuncs);
|
||||
xfree(__glXSwapBarrierFuncs);
|
||||
__glXNumHyperpipeFuncs = 0;
|
||||
__glXNumSwapBarrierFuncs = 0;
|
||||
__glXHyperpipeFuncs = NULL;
|
||||
__glXSwapBarrierFuncs = NULL;
|
||||
__glXActiveScreens = NULL;
|
||||
__glXNumActiveScreens = 0;
|
||||
for (i = 0; i < screenInfo.numScreens; i++)
|
||||
if (__glXActiveScreens[i])
|
||||
__glXActiveScreens[i]->destroy(__glXActiveScreens[i]);
|
||||
|
||||
__glXFree(__glXActiveScreens);
|
||||
__glXFree(__glXHyperpipeFuncs);
|
||||
__glXFree(__glXSwapBarrierFuncs);
|
||||
__glXNumHyperpipeFuncs = 0;
|
||||
__glXNumSwapBarrierFuncs = 0;
|
||||
__glXHyperpipeFuncs = NULL;
|
||||
__glXSwapBarrierFuncs = NULL;
|
||||
__glXActiveScreens = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,28 +51,25 @@
|
|||
** and DDX layers of the GLX server extension. The methods provide an
|
||||
** interface for context management on a screen.
|
||||
*/
|
||||
typedef struct {
|
||||
/*
|
||||
** Probe the screen and see if it supports GL rendering. It will
|
||||
** return GL_FALSE if it doesn't, GL_TRUE otherwise.
|
||||
*/
|
||||
Bool (*screenProbe)(int screen);
|
||||
|
||||
/*
|
||||
** Create a context using configuration information from modes.
|
||||
** Use imports as callbacks back to the OS. Return an opaque handle
|
||||
** on the context (NULL if failure).
|
||||
*/
|
||||
__GLinterface *(*createContext)(__GLimports *imports,
|
||||
__GLcontextModes *modes,
|
||||
__GLinterface *shareGC);
|
||||
typedef struct __GLXscreen __GLXscreen;
|
||||
typedef struct __GLXtextureFromPixmapScreen __GLXtextureFromPixmapScreen;
|
||||
|
||||
/*
|
||||
** Create a buffer using information from glxPriv. This routine
|
||||
** sets up any wrappers necessary to resize, swap or destroy the
|
||||
** buffer.
|
||||
*/
|
||||
void (*createBuffer)(__GLXdrawablePrivate *glxPriv);
|
||||
#include "glxdrawable.h"
|
||||
|
||||
struct __GLXtextureFromPixmapScreen {
|
||||
int (*getTexTarget) (__GLXscreen *screen,
|
||||
__GLXpixmap *pixmap);
|
||||
};
|
||||
|
||||
struct __GLXscreen {
|
||||
void (*destroy)(__GLXscreen *screen);
|
||||
|
||||
__GLXcontext *(*createContext)(__GLXscreen *screen,
|
||||
__GLcontextModes *modes,
|
||||
__GLXcontext *shareContext);
|
||||
|
||||
ScreenPtr pScreen;
|
||||
|
||||
/**
|
||||
* Linked list of valid context modes for this screen.
|
||||
|
|
@ -94,10 +91,14 @@ typedef struct {
|
|||
*/
|
||||
Bool (*WrappedPositionWindow)(WindowPtr pWin, int x, int y);
|
||||
|
||||
} __GLXscreenInfo;
|
||||
__GLXtextureFromPixmapScreen *textureFromPixmap;
|
||||
};
|
||||
|
||||
|
||||
extern void __glXScreenInit(GLint);
|
||||
extern void __glXScreenReset(void);
|
||||
void __glXScreenInit(__GLXscreen *screen, ScreenPtr pScreen);
|
||||
void __glXScreenDestroy(__GLXscreen *screen);
|
||||
|
||||
void __glXInitScreens(void);
|
||||
extern void __glXResetScreens(void);
|
||||
|
||||
#endif /* !__GLX_screens_h__ */
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@
|
|||
#include <scrnintstr.h>
|
||||
#include "GL/glx_ansic.h"
|
||||
|
||||
|
||||
/*
|
||||
** The X header misc.h defines these math functions.
|
||||
*/
|
||||
|
|
@ -65,17 +64,9 @@
|
|||
#include <GL/glxproto.h>
|
||||
#include <GL/glxint.h>
|
||||
|
||||
/* XXX: should go into glxext.h */
|
||||
#ifndef GLX_EXT_render_texture
|
||||
#define GLX_TEXTURE_TARGET_EXT 0x6001
|
||||
#define GLX_TEXTURE_2D_EXT 0x6002
|
||||
#define GLX_TEXTURE_RECTANGLE_EXT 0x6003
|
||||
#define GLX_NO_TEXTURE_EXT 0x6004
|
||||
#define GLX_FRONT_LEFT_EXT 0x6005
|
||||
#endif
|
||||
|
||||
/* For glxscreens.h */
|
||||
typedef struct __GLXdrawablePrivateRec __GLXdrawablePrivate;
|
||||
typedef struct __GLXdrawable __GLXdrawable;
|
||||
typedef struct __GLXcontext __GLXcontext;
|
||||
|
||||
#include "glxscreens.h"
|
||||
#include "glxdrawable.h"
|
||||
|
|
@ -100,15 +91,19 @@ typedef XID GLXContextID;
|
|||
typedef XID GLXPixmap;
|
||||
typedef XID GLXDrawable;
|
||||
|
||||
typedef struct __GLXcontextRec *GLXContext;
|
||||
typedef struct __GLXclientStateRec __GLXclientState;
|
||||
|
||||
extern __GLXscreenInfo *__glXActiveScreens;
|
||||
extern __GLXscreen **__glXActiveScreens;
|
||||
extern GLint __glXNumActiveScreens;
|
||||
extern __GLXscreenInfo *__glXgetActiveScreen(int num);
|
||||
extern __GLXscreen *__glXgetActiveScreen(int num);
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
void GlxSetVisualConfigs(int nconfigs,
|
||||
__GLXvisualConfig *configs, void **privates);
|
||||
|
||||
void __glXScreenInitVisuals(__GLXscreen *screen);
|
||||
|
||||
/*
|
||||
** The last context used (from the server's persective) is cached.
|
||||
*/
|
||||
|
|
@ -125,6 +120,20 @@ extern __GLXcontext *__glXForceCurrent(__GLXclientState*, GLXContextTag, int*);
|
|||
|
||||
/************************************************************************/
|
||||
|
||||
typedef struct __GLXprovider __GLXprovider;
|
||||
struct __GLXprovider {
|
||||
__GLXscreen *(*screenProbe)(ScreenPtr pScreen);
|
||||
const char *name;
|
||||
__GLXprovider *next;
|
||||
};
|
||||
|
||||
void GlxPushProvider(__GLXprovider *provider);
|
||||
|
||||
void __glXsetEnterLeaveServerFuncs(void (*enter)(void),
|
||||
void (*leave)(void));
|
||||
void __glXenterServer(void);
|
||||
void __glXleaveServer(void);
|
||||
|
||||
/*
|
||||
** State kept per client.
|
||||
*/
|
||||
|
|
@ -230,6 +239,8 @@ extern void __glXSwapQueryVersionReply(ClientPtr client,
|
|||
extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client,
|
||||
xGLXQueryContextInfoEXTReply *reply,
|
||||
int *buf);
|
||||
extern void __glXSwapGetDrawableAttributesReply(ClientPtr client,
|
||||
xGLXGetDrawableAttributesReply *reply, CARD32 *buf);
|
||||
extern void glxSwapQueryExtensionsStringReply(ClientPtr client,
|
||||
xGLXQueryExtensionsStringReply *reply, char *buf);
|
||||
extern void glxSwapQueryServerStringReply(ClientPtr client,
|
||||
|
|
|
|||
333
GL/glx/glxutil.c
333
GL/glx/glxutil.c
|
|
@ -40,13 +40,14 @@
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "glxserver.h"
|
||||
#include <GL/glxtokens.h>
|
||||
#include <unpack.h>
|
||||
#include <pixmapstr.h>
|
||||
#include <windowstr.h>
|
||||
#include "glxutil.h"
|
||||
#include "glxbuf.h"
|
||||
#include "GL/glx_ansic.h"
|
||||
#include "GL/internal/glcore.h"
|
||||
#include "GL/glxint.h"
|
||||
|
|
@ -54,10 +55,6 @@
|
|||
|
||||
/************************************************************************/
|
||||
|
||||
void __glXNop(void) {}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/* Memory Allocation for GLX */
|
||||
|
||||
void *
|
||||
|
|
@ -91,7 +88,7 @@ __glXCalloc(size_t numElements, size_t elementSize)
|
|||
/* XXX: handle out of memory error */
|
||||
return NULL;
|
||||
}
|
||||
__glXMemset(addr, 0, size);
|
||||
memset(addr, 0, size);
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
|
@ -142,13 +139,13 @@ __glXAssociateContext(__GLXcontext *glxc)
|
|||
glxc->nextDrawPriv = glxc->drawPriv->drawGlxc;
|
||||
glxc->drawPriv->drawGlxc = glxc;
|
||||
|
||||
__glXRefDrawablePrivate(glxc->drawPriv);
|
||||
__glXRefDrawable(glxc->drawPriv);
|
||||
|
||||
|
||||
glxc->nextReadPriv = glxc->readPriv->readGlxc;
|
||||
glxc->readPriv->readGlxc = glxc;
|
||||
|
||||
__glXRefDrawablePrivate(glxc->readPriv);
|
||||
__glXRefDrawable(glxc->readPriv);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -171,7 +168,7 @@ __glXDeassociateContext(__GLXcontext *glxc)
|
|||
prev->nextDrawPriv = curr->nextDrawPriv;
|
||||
}
|
||||
curr->nextDrawPriv = NULL;
|
||||
__glXUnrefDrawablePrivate(glxc->drawPriv);
|
||||
__glXUnrefDrawable(glxc->drawPriv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -189,330 +186,76 @@ __glXDeassociateContext(__GLXcontext *glxc)
|
|||
prev->nextReadPriv = curr->nextReadPriv;
|
||||
}
|
||||
curr->nextReadPriv = NULL;
|
||||
__glXUnrefDrawablePrivate(glxc->readPriv);
|
||||
__glXUnrefDrawable(glxc->readPriv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
void
|
||||
__glXGetDrawableSize(__GLdrawablePrivate *glPriv,
|
||||
GLint *x, GLint *y, GLuint *width, GLuint *height)
|
||||
{
|
||||
__GLXdrawablePrivate *glxPriv = (__GLXdrawablePrivate *)glPriv->other;
|
||||
|
||||
if (glxPriv) {
|
||||
*x = glxPriv->xorigin;
|
||||
*y = glxPriv->yorigin;
|
||||
*width = glxPriv->width;
|
||||
*height = glxPriv->height;
|
||||
} else {
|
||||
*x = *y = *width = *height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GLboolean
|
||||
__glXResizeDrawable(__GLdrawablePrivate *glPriv)
|
||||
{
|
||||
/* nothing to be done here */
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* accessing the drawable private */
|
||||
|
||||
static void
|
||||
LockDP(__GLdrawablePrivate *glPriv, __GLcontext *gc)
|
||||
{
|
||||
__GLinterface *glci = (__GLinterface *) gc;
|
||||
__GLXcontext *glxc = (__GLXcontext *) glci->imports.other;
|
||||
|
||||
/* quick exit test */
|
||||
if ((glxc->pendingState &
|
||||
(__GLX_PENDING_RESIZE |
|
||||
__GLX_PENDING_DESTROY |
|
||||
__GLX_PENDING_SWAP)) == 0x0)
|
||||
return;
|
||||
|
||||
/* some pending state. Deal with it */
|
||||
if (glxc->pendingState & __GLX_PENDING_RESIZE) {
|
||||
glxc->pendingState &= ~__GLX_PENDING_RESIZE;
|
||||
|
||||
(*glci->exports.notifyResize)(gc);
|
||||
assert((glxc->pendingState & __GLX_PENDING_RESIZE) == 0x0);
|
||||
}
|
||||
if (glxc->pendingState & __GLX_PENDING_DESTROY) {
|
||||
glxc->pendingState &= ~__GLX_PENDING_DESTROY;
|
||||
|
||||
assert(glxc->drawPriv->xorigin == 0);
|
||||
assert(glxc->drawPriv->yorigin == 0);
|
||||
assert(glxc->drawPriv->width == 0);
|
||||
assert(glxc->drawPriv->height == 0);
|
||||
assert(glxc->readPriv->xorigin == 0);
|
||||
assert(glxc->readPriv->yorigin == 0);
|
||||
assert(glxc->readPriv->width == 0);
|
||||
assert(glxc->readPriv->height == 0);
|
||||
(*glci->exports.notifyDestroy)(gc);
|
||||
__glXDeassociateContext(glxc);
|
||||
assert((glxc->pendingState & __GLX_PENDING_DESTROY) == 0x0);
|
||||
}
|
||||
if (glxc->pendingState & __GLX_PENDING_SWAP) {
|
||||
|
||||
glxc->pendingState &= ~__GLX_PENDING_SWAP;
|
||||
|
||||
(*glci->exports.notifySwapBuffers)(gc);
|
||||
assert((glxc->pendingState & __GLX_PENDING_SWAP) == 0x0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
UnlockDP(__GLdrawablePrivate *glPriv)
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Drawable private stuff */
|
||||
|
||||
void
|
||||
__glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv)
|
||||
__glXRefDrawable(__GLXdrawable *glxPriv)
|
||||
{
|
||||
glxPriv->refCount++;
|
||||
}
|
||||
|
||||
void
|
||||
__glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv)
|
||||
__glXUnrefDrawable(__GLXdrawable *glxPriv)
|
||||
{
|
||||
glxPriv->refCount--;
|
||||
if (glxPriv->refCount == 0) {
|
||||
__glXDestroyDrawablePrivate(glxPriv);
|
||||
/* remove the drawable from the drawable list */
|
||||
FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE);
|
||||
glxPriv->destroy(glxPriv);
|
||||
}
|
||||
}
|
||||
|
||||
__GLXdrawablePrivate *
|
||||
__glXCreateDrawablePrivate(DrawablePtr pDraw, XID drawId,
|
||||
__GLcontextModes *modes)
|
||||
{
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
__GLdrawablePrivate *glPriv;
|
||||
__GLXscreenInfo *pGlxScreen;
|
||||
|
||||
glxPriv = (__GLXdrawablePrivate *) __glXMalloc(sizeof(*glxPriv));
|
||||
__glXMemset(glxPriv, 0, sizeof(__GLXdrawablePrivate));
|
||||
|
||||
glxPriv->type = pDraw->type;
|
||||
glxPriv->pDraw = pDraw;
|
||||
glxPriv->drawId = drawId;
|
||||
|
||||
/* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */
|
||||
glxPriv->pGlxPixmap = (__GLXpixmap *)
|
||||
LookupIDByType(drawId, __glXPixmapRes);
|
||||
/* since we are creating the drawablePrivate, drawId should be new */
|
||||
if (!AddResource(drawId, __glXDrawableRes, glxPriv)) {
|
||||
/* oops! */
|
||||
__glXFree(glxPriv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* fill up glPriv */
|
||||
glPriv = &glxPriv->glPriv;
|
||||
glPriv->modes = (__GLcontextModes *) __glXMalloc(sizeof(__GLcontextModes));
|
||||
*glPriv->modes = *modes;
|
||||
glPriv->malloc = __glXMalloc;
|
||||
glPriv->calloc = __glXCalloc;
|
||||
glPriv->realloc = __glXRealloc;
|
||||
glPriv->free = __glXFree;
|
||||
glPriv->addSwapRect = NULL;
|
||||
glPriv->setClipRect = (void (*)(__GLdrawablePrivate *, GLint, GLint, GLsizei, GLsizei)) __glXNop;
|
||||
glPriv->lockDP = LockDP;
|
||||
glPriv->unlockDP = UnlockDP;
|
||||
glPriv->getDrawableSize = __glXGetDrawableSize;
|
||||
glPriv->resize = __glXResizeDrawable;
|
||||
glPriv->other = glxPriv;
|
||||
|
||||
/* allocate a one-rect ownership region */
|
||||
glPriv->ownershipRegion.rects =
|
||||
(__GLregionRect *)__glXCalloc(1, sizeof(__GLregionRect));
|
||||
glPriv->ownershipRegion.numRects = 1;
|
||||
|
||||
glxPriv->freeBuffers = __glXFreeBuffers;
|
||||
glxPriv->updatePalette = (void (*)(__GLXdrawablePrivate *)) __glXNop;
|
||||
|
||||
pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
|
||||
|
||||
if (glxPriv->type == DRAWABLE_WINDOW) {
|
||||
VisualID vid = wVisual((WindowPtr)pDraw);
|
||||
|
||||
glxPriv->modes = _gl_context_modes_find_visual( pGlxScreen->modes, vid );
|
||||
__glXFBInitDrawable(glxPriv, modes);
|
||||
} else {
|
||||
glxPriv->modes = glxPriv->pGlxPixmap->modes;
|
||||
__glXPixInitDrawable(glxPriv, modes);
|
||||
}
|
||||
|
||||
/* initialize the core's private buffer information */
|
||||
(*pGlxScreen->createBuffer)(glxPriv);
|
||||
|
||||
return glxPriv;
|
||||
}
|
||||
|
||||
GLboolean
|
||||
__glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv)
|
||||
__glXDrawableInit(__GLXdrawable *drawable,
|
||||
__GLXcontext *ctx, DrawablePtr pDraw, XID drawId)
|
||||
{
|
||||
__GLdrawablePrivate *glPriv = &glxPriv->glPriv;
|
||||
drawable->type = pDraw->type;
|
||||
drawable->pDraw = pDraw;
|
||||
drawable->drawId = drawId;
|
||||
drawable->refCount = 1;
|
||||
|
||||
/* remove the drawable from the drawable list */
|
||||
FreeResourceByType(glxPriv->drawId, __glXDrawableRes, FALSE);
|
||||
|
||||
/* Have the core free any memory it may have attached to the drawable */
|
||||
if (glPriv->freePrivate) {
|
||||
(*glPriv->freePrivate)(glPriv);
|
||||
}
|
||||
|
||||
/* Free any framebuffer memory attached to the drawable */
|
||||
if (glxPriv->freeBuffers) {
|
||||
(*glxPriv->freeBuffers)(glxPriv);
|
||||
}
|
||||
|
||||
/* Free the drawable Private */
|
||||
__glXFree(glxPriv->glPriv.modes);
|
||||
__glXFree(glxPriv->glPriv.ownershipRegion.rects);
|
||||
__glXFree(glxPriv);
|
||||
/* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */
|
||||
drawable->pGlxPixmap = (__GLXpixmap *)
|
||||
LookupIDByType(drawId, __glXPixmapRes);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
__GLXdrawablePrivate *
|
||||
__glXFindDrawablePrivate(XID drawId)
|
||||
__GLXdrawable *
|
||||
__glXFindDrawable(XID drawId)
|
||||
{
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
__GLXdrawable *glxPriv;
|
||||
|
||||
glxPriv = (__GLXdrawablePrivate *)LookupIDByType(drawId, __glXDrawableRes);
|
||||
glxPriv = (__GLXdrawable *)LookupIDByType(drawId, __glXDrawableRes);
|
||||
|
||||
return glxPriv;
|
||||
}
|
||||
|
||||
__GLXdrawablePrivate *
|
||||
__glXGetDrawablePrivate(DrawablePtr pDraw, XID drawId,
|
||||
__GLcontextModes *modes)
|
||||
__GLXdrawable *
|
||||
__glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId)
|
||||
{
|
||||
__GLXdrawablePrivate *glxPriv;
|
||||
__GLXdrawable *glxPriv;
|
||||
|
||||
glxPriv = __glXFindDrawablePrivate(drawId);
|
||||
glxPriv = __glXFindDrawable(drawId);
|
||||
|
||||
if (glxPriv == NULL) {
|
||||
glxPriv = __glXCreateDrawablePrivate(pDraw, drawId, modes);
|
||||
if (glxPriv) {
|
||||
__glXRefDrawablePrivate(glxPriv);
|
||||
if (glxPriv == NULL)
|
||||
{
|
||||
glxPriv = ctx->createDrawable(ctx, pDraw, drawId);
|
||||
|
||||
/* since we are creating the drawablePrivate, drawId should be new */
|
||||
if (!AddResource(drawId, __glXDrawableRes, glxPriv))
|
||||
{
|
||||
glxPriv->destroy (glxPriv);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return glxPriv;
|
||||
}
|
||||
|
||||
void
|
||||
__glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv)
|
||||
{
|
||||
if (glxPriv) {
|
||||
if (glxPriv->pDraw) {
|
||||
glxPriv->xorigin = glxPriv->pDraw->x;
|
||||
glxPriv->yorigin = glxPriv->pDraw->y;
|
||||
glxPriv->width = glxPriv->pDraw->width;
|
||||
glxPriv->height = glxPriv->pDraw->height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** resize/move the drawable. Called during the actual resize callback
|
||||
** to update the drawable side of the buffers
|
||||
*/
|
||||
GLboolean
|
||||
__glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv)
|
||||
{
|
||||
__GLdrawablePrivate *glPriv = &glxPriv->glPriv;
|
||||
GLint x, y;
|
||||
GLuint w, h;
|
||||
#if defined(__GL_ALIGNED_BUFFERS)
|
||||
GLint xAlignment, yAlignment;
|
||||
GLint xOffset, yOffset;
|
||||
GLint xStart, xEnd;
|
||||
GLint yStart, yEnd;
|
||||
GLuint xAlignedMask, yAlignedMask;
|
||||
#endif
|
||||
GLboolean status = GL_TRUE;
|
||||
|
||||
__glXCacheDrawableSize(glxPriv);
|
||||
|
||||
w = glxPriv->width;
|
||||
h = glxPriv->height;
|
||||
x = glxPriv->xorigin;
|
||||
y = glxPriv->yorigin;
|
||||
|
||||
#if defined(__GL_ALIGNED_BUFFERS)
|
||||
xAlignment = glPriv->xAlignment;
|
||||
yAlignment = glPriv->yAlignment;
|
||||
|
||||
xOffset = x & (xAlignment-1);
|
||||
yOffset = y & (yAlignment-1);
|
||||
|
||||
xAlignedMask = ~(xAlignment-1);
|
||||
yAlignedMask = ~(yAlignment-1);
|
||||
|
||||
xStart = x; xEnd = x+w;
|
||||
yStart = y; yEnd = y+h;
|
||||
|
||||
xStart &= xAlignedMask;
|
||||
if (xEnd & ~xAlignedMask) {
|
||||
xEnd = (xEnd&xAlignedMask) + xAlignment;
|
||||
}
|
||||
yStart &= yAlignedMask;
|
||||
if (yEnd & ~yAlignedMask) {
|
||||
yEnd = (yEnd&yAlignedMask) + yAlignment;
|
||||
}
|
||||
|
||||
x = xStart; y = yStart;
|
||||
w = xEnd-xStart; h = yEnd-yStart;
|
||||
#endif
|
||||
|
||||
if ((x != glPriv->xOrigin) ||
|
||||
(y != glPriv->yOrigin) ||
|
||||
#if defined(__GL_ALIGNED_BUFFERS)
|
||||
(xOffset != glPriv->xOffset) ||
|
||||
(yOffset != glPriv->yOffset) ||
|
||||
#endif
|
||||
(w != glPriv->width) ||
|
||||
(h != glPriv->height) ||
|
||||
(!w && !h)) {
|
||||
/* set up the glPriv info */
|
||||
glPriv->width = w;
|
||||
glPriv->height = h;
|
||||
glPriv->xOrigin = x;
|
||||
glPriv->yOrigin = y;
|
||||
#if defined(__GL_ALIGNED_BUFFERS)
|
||||
glPriv->xOffset = xOffset;
|
||||
glPriv->yOffset = yOffset;
|
||||
#endif
|
||||
|
||||
/* notify the buffers */
|
||||
status = __glXResizeBuffers(glPriv, x, y, w, h);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
GLuint __glFloorLog2(GLuint val)
|
||||
{
|
||||
int c = 0;
|
||||
|
||||
while (val > 1) {
|
||||
c++;
|
||||
val >>= 1;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,20 +58,23 @@ extern void __glXGetDrawableSize(__GLdrawablePrivate *glPriv,
|
|||
GLint *x, GLint *y,
|
||||
GLuint *width, GLuint *height);
|
||||
extern GLboolean __glXResizeDrawable(__GLdrawablePrivate *glPriv);
|
||||
extern GLboolean __glXResizeDrawableBuffers(__GLXdrawablePrivate *glxPriv);
|
||||
extern GLboolean __glXResizeDrawableBuffers(__GLXdrawable *glxPriv);
|
||||
|
||||
/* drawable management */
|
||||
extern void __glXRefDrawablePrivate(__GLXdrawablePrivate *glxPriv);
|
||||
extern void __glXUnrefDrawablePrivate(__GLXdrawablePrivate *glxPriv);
|
||||
extern __GLXdrawablePrivate *__glXCreateDrawablePrivate(DrawablePtr pDraw,
|
||||
XID glxpixmapId,
|
||||
__GLcontextModes *modes);
|
||||
extern GLboolean __glXDestroyDrawablePrivate(__GLXdrawablePrivate *glxPriv);
|
||||
extern __GLXdrawablePrivate *__glXFindDrawablePrivate(XID glxpixmapId);
|
||||
extern __GLXdrawablePrivate *__glXGetDrawablePrivate(DrawablePtr pDraw,
|
||||
XID glxpixmapId,
|
||||
__GLcontextModes *modes);
|
||||
extern void __glXCacheDrawableSize(__GLXdrawablePrivate *glxPriv);
|
||||
extern void __glXRefDrawable(__GLXdrawable *glxPriv);
|
||||
extern void __glXUnrefDrawable(__GLXdrawable *glxPriv);
|
||||
|
||||
extern __GLXdrawable *__glXCreateDrawable(__GLXcontext *ctx,
|
||||
DrawablePtr pDraw,
|
||||
XID glxpixmapId);
|
||||
extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, __GLXcontext *ctx,
|
||||
DrawablePtr pDraw, XID drawID);
|
||||
extern GLboolean __glXDestroyDrawable(__GLXdrawable *glxPriv);
|
||||
extern __GLXdrawable *__glXFindDrawable(XID glxpixmapId);
|
||||
extern __GLXdrawable *__glXGetDrawable(__GLXcontext *ctx,
|
||||
DrawablePtr pDraw,
|
||||
XID glxpixmapId);
|
||||
extern void __glXCacheDrawableSize(__GLXdrawable *glxPriv);
|
||||
|
||||
/* context helper routines */
|
||||
extern __GLXcontext *__glXLookupContextByTag(__GLXclientState*, GLXContextTag);
|
||||
|
|
|
|||
529
GL/glx/glxvisuals.c
Normal file
529
GL/glx/glxvisuals.c
Normal file
|
|
@ -0,0 +1,529 @@
|
|||
/*
|
||||
* Copyright © 2006 Red Hat, Inc.
|
||||
* (C) Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sub license,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* RED HAT, INC, OR PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
||||
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Kevin E. Martin <kevin@precisioninsight.com>
|
||||
* Brian Paul <brian@precisioninsight.com>
|
||||
* Kristian Høgsberg <krh@redhat.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <regionstr.h>
|
||||
#include <resource.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glxint.h>
|
||||
#include <GL/glxtokens.h>
|
||||
#include <GL/internal/glcore.h>
|
||||
#include <scrnintstr.h>
|
||||
#include <config.h>
|
||||
#include <glxserver.h>
|
||||
#include <glxscreens.h>
|
||||
#include <glxdrawable.h>
|
||||
#include <glxcontext.h>
|
||||
#include <glxext.h>
|
||||
#include <glxutil.h>
|
||||
#include <micmap.h>
|
||||
|
||||
void GlxWrapInitVisuals(miInitVisualsProcPtr *);
|
||||
|
||||
#include "glcontextmodes.h"
|
||||
|
||||
struct ScreenVisualsRec {
|
||||
int num_vis;
|
||||
void *private;
|
||||
__GLcontextModes *modes;
|
||||
};
|
||||
typedef struct ScreenVisualsRec ScreenVisuals;
|
||||
|
||||
static ScreenVisuals screenVisuals[MAXSCREENS];
|
||||
|
||||
static int numConfigs = 0;
|
||||
static __GLXvisualConfig *visualConfigs = NULL;
|
||||
static void **visualPrivates = NULL;
|
||||
|
||||
static int count_bits(unsigned int n)
|
||||
{
|
||||
int bits = 0;
|
||||
|
||||
while (n > 0) {
|
||||
if (n & 1) bits++;
|
||||
n >>= 1;
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
||||
/*
|
||||
* In the case the driver defines no GLX visuals we'll use these.
|
||||
* Note that for TrueColor and DirectColor visuals, bufferSize is the
|
||||
* sum of redSize, greenSize, blueSize and alphaSize, which may be larger
|
||||
* than the nplanes/rootDepth of the server's X11 visuals
|
||||
*/
|
||||
#define NUM_FALLBACK_CONFIGS 5
|
||||
static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = {
|
||||
/* [0] = RGB, double buffered, Z */
|
||||
{
|
||||
-1, /* vid */
|
||||
-1, /* class */
|
||||
True, /* rgba */
|
||||
-1, -1, -1, 0, /* rgba sizes */
|
||||
-1, -1, -1, 0, /* rgba masks */
|
||||
0, 0, 0, 0, /* rgba accum sizes */
|
||||
True, /* doubleBuffer */
|
||||
False, /* stereo */
|
||||
-1, /* bufferSize */
|
||||
16, /* depthSize */
|
||||
0, /* stencilSize */
|
||||
0, /* auxBuffers */
|
||||
0, /* level */
|
||||
GLX_NONE, /* visualRating */
|
||||
GLX_NONE, /* transparentPixel */
|
||||
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
|
||||
0 /* transparentIndex */
|
||||
},
|
||||
/* [1] = RGB, double buffered, Z, stencil, accum */
|
||||
{
|
||||
-1, /* vid */
|
||||
-1, /* class */
|
||||
True, /* rgba */
|
||||
-1, -1, -1, 0, /* rgba sizes */
|
||||
-1, -1, -1, 0, /* rgba masks */
|
||||
16, 16, 16, 0, /* rgba accum sizes */
|
||||
True, /* doubleBuffer */
|
||||
False, /* stereo */
|
||||
-1, /* bufferSize */
|
||||
16, /* depthSize */
|
||||
8, /* stencilSize */
|
||||
0, /* auxBuffers */
|
||||
0, /* level */
|
||||
GLX_NONE, /* visualRating */
|
||||
GLX_NONE, /* transparentPixel */
|
||||
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
|
||||
0 /* transparentIndex */
|
||||
},
|
||||
/* [2] = RGB+Alpha, double buffered, Z, stencil, accum */
|
||||
{
|
||||
-1, /* vid */
|
||||
-1, /* class */
|
||||
True, /* rgba */
|
||||
-1, -1, -1, 8, /* rgba sizes */
|
||||
-1, -1, -1, -1, /* rgba masks */
|
||||
16, 16, 16, 16, /* rgba accum sizes */
|
||||
True, /* doubleBuffer */
|
||||
False, /* stereo */
|
||||
-1, /* bufferSize */
|
||||
16, /* depthSize */
|
||||
8, /* stencilSize */
|
||||
0, /* auxBuffers */
|
||||
0, /* level */
|
||||
GLX_NONE, /* visualRating */
|
||||
GLX_NONE, /* transparentPixel */
|
||||
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
|
||||
0 /* transparentIndex */
|
||||
},
|
||||
/* [3] = RGB+Alpha, single buffered, Z, stencil, accum */
|
||||
{
|
||||
-1, /* vid */
|
||||
-1, /* class */
|
||||
True, /* rgba */
|
||||
-1, -1, -1, 8, /* rgba sizes */
|
||||
-1, -1, -1, -1, /* rgba masks */
|
||||
16, 16, 16, 16, /* rgba accum sizes */
|
||||
False, /* doubleBuffer */
|
||||
False, /* stereo */
|
||||
-1, /* bufferSize */
|
||||
16, /* depthSize */
|
||||
8, /* stencilSize */
|
||||
0, /* auxBuffers */
|
||||
0, /* level */
|
||||
GLX_NONE, /* visualRating */
|
||||
GLX_NONE, /* transparentPixel */
|
||||
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
|
||||
0 /* transparentIndex */
|
||||
},
|
||||
/* [4] = CI, double buffered, Z */
|
||||
{
|
||||
-1, /* vid */
|
||||
-1, /* class */
|
||||
False, /* rgba? (false = color index) */
|
||||
-1, -1, -1, 0, /* rgba sizes */
|
||||
-1, -1, -1, 0, /* rgba masks */
|
||||
0, 0, 0, 0, /* rgba accum sizes */
|
||||
True, /* doubleBuffer */
|
||||
False, /* stereo */
|
||||
-1, /* bufferSize */
|
||||
16, /* depthSize */
|
||||
0, /* stencilSize */
|
||||
0, /* auxBuffers */
|
||||
0, /* level */
|
||||
GLX_NONE, /* visualRating */
|
||||
GLX_NONE, /* transparentPixel */
|
||||
0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */
|
||||
0 /* transparentIndex */
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
static Bool init_visuals(int *nvisualp, VisualPtr *visualp,
|
||||
VisualID *defaultVisp,
|
||||
int ndepth, DepthPtr pdepth,
|
||||
int rootDepth)
|
||||
{
|
||||
int numRGBconfigs;
|
||||
int numCIconfigs;
|
||||
int numVisuals = *nvisualp;
|
||||
int numNewVisuals;
|
||||
int numNewConfigs;
|
||||
VisualPtr pVisual = *visualp;
|
||||
VisualPtr pVisualNew = NULL;
|
||||
VisualID *orig_vid = NULL;
|
||||
__GLcontextModes *modes;
|
||||
__GLXvisualConfig *pNewVisualConfigs = NULL;
|
||||
void **glXVisualPriv;
|
||||
void **pNewVisualPriv;
|
||||
int found_default;
|
||||
int i, j, k;
|
||||
|
||||
if (numConfigs > 0)
|
||||
numNewConfigs = numConfigs;
|
||||
else
|
||||
numNewConfigs = NUM_FALLBACK_CONFIGS;
|
||||
|
||||
/* Alloc space for the list of new GLX visuals */
|
||||
pNewVisualConfigs = (__GLXvisualConfig *)
|
||||
__glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig));
|
||||
if (!pNewVisualConfigs) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Alloc space for the list of new GLX visual privates */
|
||||
pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *));
|
||||
if (!pNewVisualPriv) {
|
||||
__glXFree(pNewVisualConfigs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
** If SetVisualConfigs was not called, then use default GLX
|
||||
** visual configs.
|
||||
*/
|
||||
if (numConfigs == 0) {
|
||||
memcpy(pNewVisualConfigs, FallbackConfigs,
|
||||
NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig));
|
||||
memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *));
|
||||
}
|
||||
else {
|
||||
/* copy driver's visual config info */
|
||||
for (i = 0; i < numConfigs; i++) {
|
||||
pNewVisualConfigs[i] = visualConfigs[i];
|
||||
pNewVisualPriv[i] = visualPrivates[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Count the number of RGB and CI visual configs */
|
||||
numRGBconfigs = 0;
|
||||
numCIconfigs = 0;
|
||||
for (i = 0; i < numNewConfigs; i++) {
|
||||
if (pNewVisualConfigs[i].rgba)
|
||||
numRGBconfigs++;
|
||||
else
|
||||
numCIconfigs++;
|
||||
}
|
||||
|
||||
/* Count the total number of visuals to compute */
|
||||
numNewVisuals = 0;
|
||||
for (i = 0; i < numVisuals; i++) {
|
||||
numNewVisuals +=
|
||||
(pVisual[i].class == TrueColor || pVisual[i].class == DirectColor)
|
||||
? numRGBconfigs : numCIconfigs;
|
||||
}
|
||||
|
||||
/* Reset variables for use with the next screen/driver's visual configs */
|
||||
visualConfigs = NULL;
|
||||
numConfigs = 0;
|
||||
|
||||
/* Alloc temp space for the list of orig VisualIDs for each new visual */
|
||||
orig_vid = (VisualID *) __glXMalloc(numNewVisuals * sizeof(VisualID));
|
||||
if (!orig_vid) {
|
||||
__glXFree(pNewVisualPriv);
|
||||
__glXFree(pNewVisualConfigs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Alloc space for the list of glXVisuals */
|
||||
modes = _gl_context_modes_create(numNewVisuals, sizeof(__GLcontextModes));
|
||||
if (modes == NULL) {
|
||||
__glXFree(orig_vid);
|
||||
__glXFree(pNewVisualPriv);
|
||||
__glXFree(pNewVisualConfigs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Alloc space for the list of glXVisualPrivates */
|
||||
glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *));
|
||||
if (!glXVisualPriv) {
|
||||
_gl_context_modes_destroy( modes );
|
||||
__glXFree(orig_vid);
|
||||
__glXFree(pNewVisualPriv);
|
||||
__glXFree(pNewVisualConfigs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Alloc space for the new list of the X server's visuals */
|
||||
pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec));
|
||||
if (!pVisualNew) {
|
||||
__glXFree(glXVisualPriv);
|
||||
_gl_context_modes_destroy( modes );
|
||||
__glXFree(orig_vid);
|
||||
__glXFree(pNewVisualPriv);
|
||||
__glXFree(pNewVisualConfigs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Initialize the new visuals */
|
||||
found_default = FALSE;
|
||||
screenVisuals[screenInfo.numScreens-1].modes = modes;
|
||||
for (i = j = 0; i < numVisuals; i++) {
|
||||
int is_rgb = (pVisual[i].class == TrueColor ||
|
||||
pVisual[i].class == DirectColor);
|
||||
|
||||
for (k = 0; k < numNewConfigs; k++) {
|
||||
if (pNewVisualConfigs[k].rgba != is_rgb)
|
||||
continue;
|
||||
|
||||
assert( modes != NULL );
|
||||
|
||||
/* Initialize the new visual */
|
||||
pVisualNew[j] = pVisual[i];
|
||||
pVisualNew[j].vid = FakeClientID(0);
|
||||
|
||||
/* Check for the default visual */
|
||||
if (!found_default && pVisual[i].vid == *defaultVisp) {
|
||||
*defaultVisp = pVisualNew[j].vid;
|
||||
found_default = TRUE;
|
||||
}
|
||||
|
||||
/* Save the old VisualID */
|
||||
orig_vid[j] = pVisual[i].vid;
|
||||
|
||||
/* Initialize the glXVisual */
|
||||
_gl_copy_visual_to_context_mode( modes, & pNewVisualConfigs[k] );
|
||||
modes->visualID = pVisualNew[j].vid;
|
||||
if (modes->fbconfigID == GLX_DONT_CARE)
|
||||
modes->fbconfigID = modes->visualID;
|
||||
|
||||
/*
|
||||
* If the class is -1, then assume the X visual information
|
||||
* is identical to what GLX needs, and take them from the X
|
||||
* visual. NOTE: if class != -1, then all other fields MUST
|
||||
* be initialized.
|
||||
*/
|
||||
if (modes->visualType == GLX_NONE) {
|
||||
modes->visualType = _gl_convert_from_x_visual_type( pVisual[i].class );
|
||||
modes->redBits = count_bits(pVisual[i].redMask);
|
||||
modes->greenBits = count_bits(pVisual[i].greenMask);
|
||||
modes->blueBits = count_bits(pVisual[i].blueMask);
|
||||
modes->alphaBits = modes->alphaBits;
|
||||
modes->redMask = pVisual[i].redMask;
|
||||
modes->greenMask = pVisual[i].greenMask;
|
||||
modes->blueMask = pVisual[i].blueMask;
|
||||
modes->alphaMask = modes->alphaMask;
|
||||
modes->rgbBits = (is_rgb)
|
||||
? (modes->redBits + modes->greenBits +
|
||||
modes->blueBits + modes->alphaBits)
|
||||
: rootDepth;
|
||||
|
||||
#ifdef COMPOSITE
|
||||
if (pVisual[i].nplanes == 32)
|
||||
modes->visualRating = GLX_NON_CONFORMANT_CONFIG;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* Save the device-dependent private for this visual */
|
||||
glXVisualPriv[j] = pNewVisualPriv[k];
|
||||
|
||||
j++;
|
||||
modes = modes->next;
|
||||
}
|
||||
}
|
||||
|
||||
assert(j <= numNewVisuals);
|
||||
|
||||
/* Save the GLX visuals in the screen structure */
|
||||
screenVisuals[screenInfo.numScreens-1].num_vis = numNewVisuals;
|
||||
screenVisuals[screenInfo.numScreens-1].private = glXVisualPriv;
|
||||
|
||||
/* Set up depth's VisualIDs */
|
||||
for (i = 0; i < ndepth; i++) {
|
||||
int numVids = 0;
|
||||
VisualID *pVids = NULL;
|
||||
int k, n = 0;
|
||||
|
||||
/* Count the new number of VisualIDs at this depth */
|
||||
for (j = 0; j < pdepth[i].numVids; j++)
|
||||
for (k = 0; k < numNewVisuals; k++)
|
||||
if (pdepth[i].vids[j] == orig_vid[k])
|
||||
numVids++;
|
||||
|
||||
/* Allocate a new list of VisualIDs for this depth */
|
||||
pVids = (VisualID *)__glXMalloc(numVids * sizeof(VisualID));
|
||||
|
||||
/* Initialize the new list of VisualIDs for this depth */
|
||||
for (j = 0; j < pdepth[i].numVids; j++)
|
||||
for (k = 0; k < numNewVisuals; k++)
|
||||
if (pdepth[i].vids[j] == orig_vid[k])
|
||||
pVids[n++] = pVisualNew[k].vid;
|
||||
|
||||
/* Update this depth's list of VisualIDs */
|
||||
__glXFree(pdepth[i].vids);
|
||||
pdepth[i].vids = pVids;
|
||||
pdepth[i].numVids = numVids;
|
||||
}
|
||||
|
||||
/* Update the X server's visuals */
|
||||
*nvisualp = numNewVisuals;
|
||||
*visualp = pVisualNew;
|
||||
|
||||
/* Free the old list of the X server's visuals */
|
||||
__glXFree(pVisual);
|
||||
|
||||
/* Clean up temporary allocations */
|
||||
__glXFree(orig_vid);
|
||||
__glXFree(pNewVisualPriv);
|
||||
__glXFree(pNewVisualConfigs);
|
||||
|
||||
/* Free the private list created by DDX HW driver */
|
||||
if (visualPrivates)
|
||||
__glXFree(visualPrivates);
|
||||
visualPrivates = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void GlxSetVisualConfigs(int nconfigs,
|
||||
__GLXvisualConfig *configs, void **privates)
|
||||
{
|
||||
numConfigs = nconfigs;
|
||||
visualConfigs = configs;
|
||||
visualPrivates = privates;
|
||||
}
|
||||
|
||||
static miInitVisualsProcPtr saveInitVisualsProc;
|
||||
|
||||
Bool GlxInitVisuals(VisualPtr *visualp, DepthPtr *depthp,
|
||||
int *nvisualp, int *ndepthp,
|
||||
int *rootDepthp, VisualID *defaultVisp,
|
||||
unsigned long sizes, int bitsPerRGB,
|
||||
int preferredVis)
|
||||
{
|
||||
Bool ret;
|
||||
|
||||
if (saveInitVisualsProc) {
|
||||
ret = saveInitVisualsProc(visualp, depthp, nvisualp, ndepthp,
|
||||
rootDepthp, defaultVisp, sizes, bitsPerRGB,
|
||||
preferredVis);
|
||||
if (!ret)
|
||||
return False;
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the visuals supported by this particular screen.
|
||||
*/
|
||||
init_visuals(nvisualp, visualp, defaultVisp,
|
||||
*ndepthp, *depthp, *rootDepthp);
|
||||
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
|
||||
void
|
||||
GlxWrapInitVisuals(miInitVisualsProcPtr *initVisProc)
|
||||
{
|
||||
saveInitVisualsProc = *initVisProc;
|
||||
*initVisProc = GlxInitVisuals;
|
||||
}
|
||||
|
||||
static void fixup_visuals(int screen)
|
||||
{
|
||||
ScreenPtr pScreen = screenInfo.screens[screen];
|
||||
ScreenVisuals *psv = &screenVisuals[screen];
|
||||
int j;
|
||||
__GLcontextModes *modes;
|
||||
|
||||
for ( modes = psv->modes ; modes != NULL ; modes = modes->next ) {
|
||||
const int vis_class = _gl_convert_to_x_visual_type( modes->visualType );
|
||||
const int nplanes = (modes->rgbBits - modes->alphaBits);
|
||||
const VisualPtr pVis = pScreen->visuals;
|
||||
|
||||
/* Find a visual that matches the GLX visual's class and size */
|
||||
for (j = 0; j < pScreen->numVisuals; j++) {
|
||||
if (pVis[j].class == vis_class &&
|
||||
(pVis[j].nplanes == nplanes
|
||||
|
||||
#ifdef COMPOSITE
|
||||
|| (pVis[j].nplanes == 32 && pVis[j].nplanes == modes->rgbBits)
|
||||
#endif
|
||||
|
||||
)) {
|
||||
|
||||
/* Fixup the masks */
|
||||
modes->redMask = pVis[j].redMask;
|
||||
modes->greenMask = pVis[j].greenMask;
|
||||
modes->blueMask = pVis[j].blueMask;
|
||||
|
||||
/* Recalc the sizes */
|
||||
modes->redBits = count_bits(modes->redMask);
|
||||
modes->greenBits = count_bits(modes->greenMask);
|
||||
modes->blueBits = count_bits(modes->blueMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __glXScreenInitVisuals(__GLXscreen *screen)
|
||||
{
|
||||
int index = screen->pScreen->myNum;
|
||||
|
||||
screen->modes = screenVisuals[index].modes;
|
||||
screen->pVisualPriv = screenVisuals[index].private;
|
||||
screen->numVisuals = screenVisuals[index].num_vis;
|
||||
screen->numUsableVisuals = screenVisuals[index].num_vis;
|
||||
|
||||
/*
|
||||
* The ordering of the rgb compenents might have been changed by the
|
||||
* driver after mi initialized them.
|
||||
*/
|
||||
fixup_visuals(index);
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <X11/Xmd.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glxproto.h>
|
||||
|
|
|
|||
|
|
@ -311,6 +311,10 @@ void __glXDispSwap_DrawArrays(GLbyte *pc)
|
|||
GLint numVals = compHeader[i].numVals;
|
||||
GLenum component = compHeader[i].component;
|
||||
|
||||
__GLX_SWAP_INT(&datatype);
|
||||
__GLX_SWAP_INT(&numVals);
|
||||
__GLX_SWAP_INT(&component);
|
||||
|
||||
swapArray(numVals, datatype, stride, numVertexes, pc);
|
||||
|
||||
switch (component) {
|
||||
|
|
@ -338,6 +342,14 @@ void __glXDispSwap_DrawArrays(GLbyte *pc)
|
|||
CALL_EnableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) );
|
||||
CALL_EdgeFlagPointer( GET_DISPATCH(), (stride, (const GLboolean *)pc) );
|
||||
break;
|
||||
case GL_SECONDARY_COLOR_ARRAY:
|
||||
CALL_EnableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) );
|
||||
CALL_SecondaryColorPointerEXT( GET_DISPATCH(), (numVals, datatype, stride, pc) );
|
||||
break;
|
||||
case GL_FOG_COORD_ARRAY:
|
||||
CALL_EnableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) );
|
||||
CALL_FogCoordPointerEXT( GET_DISPATCH(), (datatype, stride, pc) );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -354,6 +366,8 @@ void __glXDispSwap_DrawArrays(GLbyte *pc)
|
|||
CALL_DisableClientState( GET_DISPATCH(), (GL_INDEX_ARRAY) );
|
||||
CALL_DisableClientState( GET_DISPATCH(), (GL_TEXTURE_COORD_ARRAY) );
|
||||
CALL_DisableClientState( GET_DISPATCH(), (GL_EDGE_FLAG_ARRAY) );
|
||||
CALL_DisableClientState( GET_DISPATCH(), (GL_SECONDARY_COLOR_ARRAY) );
|
||||
CALL_DisableClientState( GET_DISPATCH(), (GL_FOG_COORD_ARRAY) );
|
||||
}
|
||||
|
||||
void __glXDispSwap_DrawArraysEXT(GLbyte *pc)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glxserver.h"
|
||||
#include "glxutil.h"
|
||||
#include "glxext.h"
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@
|
|||
|
||||
#ifdef XFree86Server
|
||||
|
||||
#ifdef XFree86LOADER
|
||||
#include "xf86_ansic.h"
|
||||
#endif
|
||||
#ifndef assert
|
||||
#define assert(a)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -37,7 +37,3 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#endif
|
||||
|
||||
#include "miscstruct.h"
|
||||
|
||||
#ifdef XFree86LOADER
|
||||
#include "xf86_ansic.h"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
SUBDIRS = main math array_cache swrast swrast_setup tnl shader X glapi
|
||||
SUBDIRS = main math array_cache swrast swrast_setup tnl shader X
|
||||
|
||||
noinst_LTLIBRARIES = libGLcore.la
|
||||
|
||||
libGLcore_la_CFLAGS = @DIX_CFLAGS@ -DUSE_MGL_NAMESPACE -UHAVE_CONFIG_H -DGLXEXT \
|
||||
-DXF86DRI -DGLX_DIRECT_RENDERING -DGLX_USE_DLOPEN -DGLX_USE_MESA
|
||||
|
||||
libGLcore_la_SOURCES = dummy.c
|
||||
libGLcore_la_LIBADD = main/libmain.la \
|
||||
math/libmath.la \
|
||||
|
|
@ -15,5 +12,4 @@ libGLcore_la_LIBADD = main/libmain.la \
|
|||
shader/libshader.la \
|
||||
shader/grammar/libgrammar.la \
|
||||
shader/slang/libslang.la \
|
||||
X/libX.la \
|
||||
glapi/libglapi.la
|
||||
X/libX.la
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ INCLUDES = -I@MESA_SOURCE@/include \
|
|||
|
||||
# -DXFree86Server is required because the X11 driver in Mesa thinks that
|
||||
# symbol means "being built in the server"
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ \
|
||||
-DXFree86Server -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ \
|
||||
-DXFree86Server -DUSE_MGL_NAMESPACE
|
||||
|
||||
libX_la_SOURCES = xf86glx.c \
|
||||
xf86glx_util.c \
|
||||
|
|
|
|||
1124
GL/mesa/X/xf86glx.c
1124
GL/mesa/X/xf86glx.c
File diff suppressed because it is too large
Load diff
|
|
@ -36,6 +36,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gcstruct.h>
|
||||
#include "pixmapstr.h"
|
||||
#include "xf86glx_util.h"
|
||||
|
|
|
|||
|
|
@ -43,71 +43,4 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <GL/gl.h>
|
||||
#include <GL/xmesa.h>
|
||||
|
||||
typedef struct __MESA_screenRec __MESA_screen;
|
||||
struct __MESA_screenRec {
|
||||
int num_vis;
|
||||
__GLcontextModes *modes;
|
||||
XMesaVisual *xm_vis;
|
||||
void **private;
|
||||
};
|
||||
|
||||
typedef struct __MESA_bufferRec *__MESA_buffer;
|
||||
struct __MESA_bufferRec {
|
||||
XMesaBuffer xm_buf;
|
||||
DrawablePtr pDraw;
|
||||
XMesaVisual xm_vis;
|
||||
GLboolean (*fbresize)(__GLdrawableBuffer *buf,
|
||||
GLint x, GLint y, GLuint width, GLuint height,
|
||||
__GLdrawablePrivate *glPriv, GLuint bufferMask);
|
||||
GLboolean (*fbswap)(__GLXdrawablePrivate *glxPriv);
|
||||
int (*fbbind)(__GLXdrawablePrivate *glxPriv, int buffer);
|
||||
int (*fbrelease)(__GLXdrawablePrivate *glxPriv, int buffer);
|
||||
int (*fbquery)(__GLXdrawablePrivate *glxPriv, int attribute,
|
||||
unsigned int *value);
|
||||
|
||||
};
|
||||
|
||||
extern void __MESA_setVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
|
||||
void **privates);
|
||||
extern Bool __MESA_initVisuals(VisualPtr *visualp, DepthPtr *depthp,
|
||||
int *nvisualp, int *ndepthp, int *rootDepthp,
|
||||
VisualID *defaultVisp, unsigned long sizes,
|
||||
int bitsPerRGB);
|
||||
extern Bool __MESA_screenProbe(int screen);
|
||||
|
||||
extern void __MESA_resetExtension(void);
|
||||
|
||||
extern void __MESA_createBuffer(__GLXdrawablePrivate *glxPriv);
|
||||
extern GLboolean __MESA_resizeBuffers(__GLdrawableBuffer *buf,
|
||||
GLint x, GLint y,
|
||||
GLuint width, GLuint height,
|
||||
__GLdrawablePrivate *glPriv,
|
||||
GLuint bufferMask);
|
||||
extern GLboolean __MESA_swapBuffers(__GLXdrawablePrivate *glxPriv);
|
||||
extern int __MESA_bindBuffers(__GLXdrawablePrivate *glxPriv, int buffer);
|
||||
extern int __MESA_releaseBuffers(__GLXdrawablePrivate *glxPriv, int buffer);
|
||||
extern int __MESA_queryBuffers(__GLXdrawablePrivate *glxPriv, int attribute,
|
||||
unsigned int *value);
|
||||
extern void __MESA_destroyBuffer(__GLdrawablePrivate *glPriv);
|
||||
|
||||
extern __GLinterface *__MESA_createContext(__GLimports *imports,
|
||||
__GLcontextModes *modes,
|
||||
__GLinterface *shareGC);
|
||||
extern GLboolean __MESA_destroyContext(__GLcontext *gc);
|
||||
extern GLboolean __MESA_loseCurrent(__GLcontext *gc);
|
||||
extern GLboolean __MESA_makeCurrent(__GLcontext *gc);
|
||||
extern GLboolean __MESA_shareContext(__GLcontext *gc, __GLcontext *gcShare);
|
||||
extern GLboolean __MESA_copyContext(__GLcontext *dst, const __GLcontext *src,
|
||||
GLuint mask);
|
||||
extern GLboolean __MESA_forceCurrent(__GLcontext *gc);
|
||||
|
||||
extern GLboolean __MESA_notifyResize(__GLcontext *gc);
|
||||
extern void __MESA_notifyDestroy(__GLcontext *gc);
|
||||
extern void __MESA_notifySwapBuffers(__GLcontext *gc);
|
||||
extern struct __GLdispatchStateRec *__MESA_dispatchExec(__GLcontext *gc);
|
||||
extern void __MESA_beginDispatchOverride(__GLcontext *gc);
|
||||
extern void __MESA_endDispatchOverride(__GLcontext *gc);
|
||||
|
||||
extern GLuint __glFloorLog2(GLuint val);
|
||||
|
||||
#endif /* _XF86GLXINT_H_ */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libac.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libglapi.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libmain.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
@ -34,7 +34,7 @@ nodist_libmain_la_SOURCES = accum.c \
|
|||
convolve.c \
|
||||
debug.c \
|
||||
depth.c \
|
||||
depthstencil.c \
|
||||
depthstencil.c \
|
||||
dlist.c \
|
||||
drawpix.c \
|
||||
enable.c \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libmath.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ SUBDIRS = grammar slang
|
|||
|
||||
noinst_LTLIBRARIES = libshader.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
@ -26,7 +26,7 @@ nodist_libshader_la_SOURCES = \
|
|||
nvfragparse.c \
|
||||
nvprogram.c \
|
||||
nvvertexec.c \
|
||||
nvvertparse.c \
|
||||
nvvertparse.c \
|
||||
program.c \
|
||||
shaderobjects.c \
|
||||
shaderobjects_3dlabs.c
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libgrammar.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../../X \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libslang.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../grammar \
|
||||
|
|
@ -22,10 +22,10 @@ nodist_libslang_la_SOURCES = slang_assemble_assignment.c \
|
|||
slang_assemble_constructor.c \
|
||||
slang_assemble_typeinfo.c \
|
||||
slang_compile.c \
|
||||
slang_compile_function.c \
|
||||
slang_compile_operation.c \
|
||||
slang_compile_struct.c \
|
||||
slang_compile_variable.c \
|
||||
slang_compile_function.c \
|
||||
slang_compile_operation.c \
|
||||
slang_compile_struct.c \
|
||||
slang_compile_variable.c \
|
||||
slang_execute.c \
|
||||
slang_export.c \
|
||||
slang_library_noise.c \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libswrast.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
@ -9,7 +9,7 @@ INCLUDES = -I@MESA_SOURCE@/include \
|
|||
-I../main \
|
||||
-I../math \
|
||||
-I../shader \
|
||||
-I../shader/slang \
|
||||
-I../shader/slang \
|
||||
-I../swrast \
|
||||
-I../swrast_setup \
|
||||
-I../tnl \
|
||||
|
|
@ -41,8 +41,8 @@ nodist_libswrast_la_SOURCES = s_aaline.c \
|
|||
s_readpix.c \
|
||||
s_span.c \
|
||||
s_stencil.c \
|
||||
s_texcombine.c \
|
||||
s_texfilter.c \
|
||||
s_texcombine.c \
|
||||
s_texfilter.c \
|
||||
s_texstore.c \
|
||||
s_triangle.c \
|
||||
s_zoom.c
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libss.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LTLIBRARIES = libtnl.la
|
||||
|
||||
AM_CFLAGS = @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE @DIX_CFLAGS@
|
||||
AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @MODULE_DEFINES@ @LOADER_DEFINES@ -DUSE_MGL_NAMESPACE
|
||||
|
||||
INCLUDES = -I@MESA_SOURCE@/include \
|
||||
-I../X \
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ symlink_mesa_glapi() {
|
|||
dst_dir mesa/glapi
|
||||
|
||||
action dispatch.h
|
||||
action glapi.h
|
||||
action glapi.c
|
||||
action glapi.h
|
||||
action glapioffsets.h
|
||||
action glapitable.h
|
||||
action glapitemp.h
|
||||
|
|
|
|||
|
|
@ -7,16 +7,10 @@ AM_CFLAGS = \
|
|||
|
||||
libglx_la_LDFLAGS = -avoid-version
|
||||
libglx_la_SOURCES = glxmodule.c
|
||||
libglx_la_LIBADD = $(top_builddir)/GL/glx/libglx.la
|
||||
libglx_la_LIBADD = $(top_builddir)/GL/glx/libglx.la \
|
||||
$(top_builddir)/GL/mesa/libGLcore.la
|
||||
libglx_modules = libglx.la
|
||||
|
||||
libglcore_la_LDFLAGS = -avoid-version
|
||||
libglcore_la_SOURCES = glcoremodule.c
|
||||
libglcore_la_LIBADD = $(top_builddir)/GL/mesa/libGLcore.la
|
||||
libglcore_modules = libglcore.la
|
||||
|
||||
moduledir = @XGL_MODULE_PATH@
|
||||
|
||||
module_LTLIBRARIES = \
|
||||
$(libglcore_modules) \
|
||||
$(libglx_modules)
|
||||
module_LTLIBRARIES = $(libglx_modules)
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2005 Novell, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Novell, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior permission.
|
||||
* Novell, Inc. makes no representations about the suitability of this
|
||||
* software for any purpose. It is provided "as is" without express or
|
||||
* implied warranty.
|
||||
*
|
||||
* NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
|
||||
* NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: David Reveman <davidr@novell.com>
|
||||
*/
|
||||
|
||||
#include "xglmodule.h"
|
||||
|
||||
char *
|
||||
moduleVersion (void)
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
Bool
|
||||
moduleInit (const char *module)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
153
hw/xgl/xglglx.c
153
hw/xgl/xglglx.c
|
|
@ -38,36 +38,33 @@ FILE *__xglGLXLogFp;
|
|||
#endif
|
||||
|
||||
static void *glXHandle = 0;
|
||||
static void *glCoreHandle = 0;
|
||||
|
||||
#define SYM(ptr, name) { (void **) &(ptr), (name) }
|
||||
|
||||
__GLXextensionInfo *__xglExtensionInfo;
|
||||
__GLXscreenInfo *__xglScreenInfo;
|
||||
__GLXprovider *__xglMesaProvider;
|
||||
|
||||
void *(*__glcore_DDXScreenInfo) (void);
|
||||
void *(*__glcore_DDXExtensionInfo) (void);
|
||||
void *(*__GlxGetMesaProvider) (void);
|
||||
|
||||
void
|
||||
GlxSetVisualConfigs (int nconfigs,
|
||||
__GLXvisualConfig *configs,
|
||||
void **privates)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.setVisualConfigs) (nconfigs, configs, privates);
|
||||
}
|
||||
|
||||
void
|
||||
GlxExtensionInit (void)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.extensionInit) ();
|
||||
}
|
||||
|
||||
void
|
||||
GlxWrapInitVisuals (miInitVisualsProcPtr *initVisuals)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.wrapInitVisuals) (initVisuals);
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +79,7 @@ GlxInitVisuals (VisualPtr *visualp,
|
|||
int bitsPerRGB,
|
||||
int preferredVis)
|
||||
{
|
||||
if (glXHandle && glCoreHandle)
|
||||
if (glXHandle)
|
||||
return (*__xglGLXFunc.initVisuals) (visualp, depthp, nvisualp, ndepthp,
|
||||
rootDepthp, defaultVisp, sizes,
|
||||
bitsPerRGB, preferredVis);
|
||||
|
|
@ -93,57 +90,49 @@ GlxInitVisuals (VisualPtr *visualp,
|
|||
void
|
||||
GlxFlushContextCache (void)
|
||||
{
|
||||
(*__xglGLXFunc.flushContextCache) ();
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.flushContextCache) ();
|
||||
}
|
||||
|
||||
void
|
||||
GlxSetRenderTables (struct _glapi_table *table)
|
||||
{
|
||||
(*__xglGLXFunc.setRenderTables) (table);
|
||||
}
|
||||
|
||||
void *
|
||||
__glXglDDXScreenInfo (void)
|
||||
{
|
||||
return __xglScreenInfo;
|
||||
}
|
||||
|
||||
void *
|
||||
__glXglDDXExtensionInfo( void)
|
||||
{
|
||||
return __xglExtensionInfo;
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.setRenderTables) (table);
|
||||
}
|
||||
|
||||
void
|
||||
_gl_copy_visual_to_context_mode (__GLcontextModes *mode,
|
||||
const __GLXvisualConfig *config)
|
||||
GlxPushProvider (__GLXprovider *provider)
|
||||
{
|
||||
(*__xglGLXFunc.copy_visual_to_context_mode) (mode, config);
|
||||
}
|
||||
|
||||
__GLcontextModes *
|
||||
_gl_context_modes_create (unsigned count,
|
||||
size_t minimumSize)
|
||||
{
|
||||
return (*__xglGLXFunc.context_modes_create) (count, minimumSize);
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.pushProvider) (provider);
|
||||
}
|
||||
|
||||
void
|
||||
_gl_context_modes_destroy (__GLcontextModes *modes)
|
||||
GlxScreenInit (__GLXscreen *screen,
|
||||
ScreenPtr pScreen)
|
||||
{
|
||||
(*__xglGLXFunc.context_modes_destroy) (modes);
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.screenInit) (screen, pScreen);
|
||||
}
|
||||
|
||||
GLint
|
||||
_gl_convert_from_x_visual_type (int visualType)
|
||||
void
|
||||
GlxScreenDestroy (__GLXscreen *screen)
|
||||
{
|
||||
return (*__xglGLXFunc.convert_from_x_visual_type) (visualType);
|
||||
if (glXHandle)
|
||||
(*__xglGLXFunc.screenDestroy) (screen);
|
||||
}
|
||||
|
||||
GLint
|
||||
_gl_convert_to_x_visual_type (int visualType)
|
||||
GLboolean
|
||||
GlxDrawableInit (__GLXdrawable *drawable,
|
||||
__GLXcontext *ctx,
|
||||
DrawablePtr pDrawable,
|
||||
XID drawId)
|
||||
{
|
||||
return (*__xglGLXFunc.convert_to_x_visual_type) (visualType);
|
||||
if (glXHandle)
|
||||
return (*__xglGLXFunc.drawableInit) (drawable, ctx, pDrawable, drawId);
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
|
|
@ -160,16 +149,12 @@ xglLoadGLXModules (void)
|
|||
SYM (__xglGLXFunc.initVisuals, "GlxInitVisuals"),
|
||||
SYM (__xglGLXFunc.flushContextCache, "__glXFlushContextCache"),
|
||||
SYM (__xglGLXFunc.setRenderTables, "GlxSetRenderTables"),
|
||||
SYM (__xglGLXFunc.copy_visual_to_context_mode,
|
||||
"_gl_copy_visual_to_context_mode"),
|
||||
SYM (__xglGLXFunc.context_modes_create,
|
||||
"_gl_context_modes_create"),
|
||||
SYM (__xglGLXFunc.context_modes_destroy,
|
||||
"_gl_context_modes_destroy"),
|
||||
SYM (__xglGLXFunc.convert_from_x_visual_type,
|
||||
"_gl_convert_from_x_visual_type"),
|
||||
SYM (__xglGLXFunc.convert_to_x_visual_type,
|
||||
"_gl_convert_to_x_visual_type")
|
||||
SYM (__xglGLXFunc.pushProvider, "GlxPushProvider"),
|
||||
SYM (__xglGLXFunc.screenInit, "__glXScreenInit"),
|
||||
SYM (__xglGLXFunc.screenDestroy, "__glXScreenDestroy"),
|
||||
SYM (__xglGLXFunc.drawableInit, "__glXDrawableInit"),
|
||||
|
||||
SYM (__GlxGetMesaProvider, "GlxGetMesaProvider")
|
||||
};
|
||||
|
||||
glXHandle = xglLoadModule ("glx", RTLD_NOW | RTLD_LOCAL);
|
||||
|
|
@ -183,65 +168,13 @@ xglLoadGLXModules (void)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!glCoreHandle)
|
||||
{
|
||||
xglSymbolRec ddxSym[] = {
|
||||
SYM (__glcore_DDXExtensionInfo, "__glXglDDXExtensionInfo"),
|
||||
SYM (__glcore_DDXScreenInfo, "__glXglDDXScreenInfo")
|
||||
};
|
||||
__xglMesaProvider = __GlxGetMesaProvider ();
|
||||
|
||||
glCoreHandle = xglLoadModule ("glcore", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!glCoreHandle)
|
||||
return FALSE;
|
||||
|
||||
if (!xglLookupSymbols (glCoreHandle, ddxSym,
|
||||
sizeof (ddxSym) / sizeof(ddxSym[0])))
|
||||
if (!xglLoadHashFuncs (glXHandle))
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
__xglScreenInfo = __glcore_DDXScreenInfo ();
|
||||
__xglExtensionInfo = __glcore_DDXExtensionInfo ();
|
||||
|
||||
if (__xglScreenInfo && __xglExtensionInfo)
|
||||
{
|
||||
xglSymbolRec sym[] = {
|
||||
SYM (__xglScreenInfo->screenProbe, "__MESA_screenProbe"),
|
||||
SYM (__xglScreenInfo->createContext, "__MESA_createContext"),
|
||||
SYM (__xglScreenInfo->createBuffer, "__MESA_createBuffer"),
|
||||
SYM (__xglExtensionInfo->resetExtension,
|
||||
"__MESA_resetExtension"),
|
||||
SYM (__xglExtensionInfo->initVisuals, "__MESA_initVisuals"),
|
||||
SYM (__xglExtensionInfo->setVisualConfigs,
|
||||
"__MESA_setVisualConfigs")
|
||||
};
|
||||
|
||||
if (!xglLookupSymbols (glCoreHandle, sym,
|
||||
sizeof (sym) / sizeof (sym[0])))
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!xglLoadHashFuncs (glCoreHandle))
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
xglUnloadModule (glXHandle);
|
||||
glXHandle = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -264,12 +197,6 @@ xglUnloadGLXModules (void)
|
|||
xglUnloadModule (glXHandle);
|
||||
glXHandle = 0;
|
||||
}
|
||||
|
||||
if (glCoreHandle)
|
||||
{
|
||||
xglUnloadModule (glCoreHandle);
|
||||
glCoreHandle = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,16 +48,14 @@ typedef struct _xglGLXFunc {
|
|||
int bitsPerRGB,
|
||||
int preferredVis);
|
||||
void (*flushContextCache) (void);
|
||||
void *(*DDXExtensionInfo) (void);
|
||||
void *(*DDXScreenInfo) (void);
|
||||
void (*setRenderTables) (struct _glapi_table *table);
|
||||
void (*copy_visual_to_context_mode) (__GLcontextModes *mode,
|
||||
const __GLXvisualConfig *config);
|
||||
__GLcontextModes *(*context_modes_create) (unsigned count,
|
||||
size_t minimumSize);
|
||||
void (*context_modes_destroy) (__GLcontextModes *modes);
|
||||
GLint (*convert_from_x_visual_type) (int visualType);
|
||||
GLint (*convert_to_x_visual_type) (int visualType);
|
||||
void (*pushProvider) (__GLXprovider *provider);
|
||||
void (*screenInit) (__GLXscreen *screen, ScreenPtr pScreen);
|
||||
void (*screenDestroy) (__GLXscreen *screen);
|
||||
GLboolean (*drawableInit) (__GLXdrawable *drawable,
|
||||
__GLXcontext *ctx,
|
||||
DrawablePtr pDrawable,
|
||||
XID drawId);
|
||||
} xglGLXFuncRec, *xglGLXFuncPtr;
|
||||
|
||||
extern xglGLXFuncRec __xglGLXFunc;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue