2008-11-02 08:26:08 -07:00
|
|
|
/*
|
|
|
|
* Copyright © 2008 George Sapountzis <gsap7@yahoo.gr>
|
|
|
|
* Copyright © 2008 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 the
|
|
|
|
* copyright holders not be used in advertising or publicity
|
|
|
|
* pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. The copyright holders make no
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied
|
|
|
|
* warranty.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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 <GL/gl.h>
|
|
|
|
#include <GL/internal/dri_interface.h>
|
|
|
|
#include <GL/glxtokens.h>
|
|
|
|
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "os.h"
|
|
|
|
|
|
|
|
#include "glxserver.h"
|
|
|
|
#include "glxutil.h"
|
|
|
|
#include "glxdricommon.h"
|
|
|
|
|
|
|
|
#include "extension_string.h"
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* RTLD_LOCAL is not defined on Cygwin */
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#ifndef RTLD_LOCAL
|
|
|
|
#define RTLD_LOCAL 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef struct __GLXDRIscreen __GLXDRIscreen;
|
|
|
|
typedef struct __GLXDRIcontext __GLXDRIcontext;
|
2008-11-02 08:26:08 -07:00
|
|
|
typedef struct __GLXDRIdrawable __GLXDRIdrawable;
|
|
|
|
|
|
|
|
struct __GLXDRIscreen {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXscreen base;
|
|
|
|
__DRIscreen *driScreen;
|
|
|
|
void *driver;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
const __DRIcoreExtension *core;
|
|
|
|
const __DRIswrastExtension *swrast;
|
|
|
|
const __DRIcopySubBufferExtension *copySubBuffer;
|
|
|
|
const __DRItexBufferExtension *texBuffer;
|
2012-06-10 07:21:05 -06:00
|
|
|
const __DRIconfig **driConfigs;
|
2008-11-02 08:26:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct __GLXDRIcontext {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXcontext base;
|
|
|
|
__DRIcontext *driContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct __GLXDRIdrawable {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXdrawable base;
|
|
|
|
__DRIdrawable *driDrawable;
|
|
|
|
__GLXDRIscreen *screen;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
GCPtr gc; /* scratch GC for span drawing */
|
|
|
|
GCPtr swapgc; /* GC for swapping the color buffers */
|
2008-11-02 08:26:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdrawableDestroy(__GLXdrawable * drawable)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
|
|
|
|
const __DRIcoreExtension *core = private->screen->core;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*core->destroyDrawable) (private->driDrawable);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
FreeGC(private->gc, (GContext) 0);
|
|
|
|
FreeGC(private->swapgc, (GContext) 0);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
__glXDrawableRelease(drawable);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(private);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static GLboolean
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdrawableSwapBuffers(ClientPtr client, __GLXdrawable * drawable)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
|
|
|
|
const __DRIcoreExtension *core = private->screen->core;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*core->swapBuffers) (private->driDrawable);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdrawableCopySubBuffer(__GLXdrawable * basePrivate,
|
|
|
|
int x, int y, int w, int h)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate;
|
|
|
|
const __DRIcopySubBufferExtension *copySubBuffer =
|
2012-06-10 07:21:05 -06:00
|
|
|
private->screen->copySubBuffer;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (copySubBuffer)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*copySubBuffer->copySubBuffer) (private->driDrawable, x, y, w, h);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextDestroy(__GLXcontext * baseContext)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->core->destroyContext) (context->driContext);
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXContextDestroy(&context->base);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(context);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextMakeCurrent(__GLXcontext * baseContext)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
|
|
|
__GLXDRIdrawable *draw = (__GLXDRIdrawable *) baseContext->drawPriv;
|
|
|
|
__GLXDRIdrawable *read = (__GLXDRIdrawable *) baseContext->readPriv;
|
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*screen->core->bindContext) (context->driContext,
|
|
|
|
draw->driDrawable, read->driDrawable);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextLoseCurrent(__GLXcontext * baseContext)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*screen->core->unbindContext) (context->driContext);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextCopy(__GLXcontext * baseDst, __GLXcontext * baseSrc,
|
|
|
|
unsigned long mask)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *dst = (__GLXDRIcontext *) baseDst;
|
|
|
|
__GLXDRIcontext *src = (__GLXDRIcontext *) baseSrc;
|
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) dst->base.pGlxScreen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*screen->core->copyContext) (dst->driContext,
|
|
|
|
src->driContext, mask);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIbindTexImage(__GLXcontext * baseContext,
|
|
|
|
int buffer, __GLXdrawable * glxPixmap)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *drawable = (__GLXDRIdrawable *) glxPixmap;
|
|
|
|
const __DRItexBufferExtension *texBuffer = drawable->screen->texBuffer;
|
|
|
|
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
|
|
|
|
|
|
|
if (texBuffer == NULL)
|
|
|
|
return Success;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
#if __DRI_TEX_BUFFER_VERSION >= 2
|
|
|
|
if (texBuffer->base.version >= 2 && texBuffer->setTexBuffer2 != NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
(*texBuffer->setTexBuffer2) (context->driContext,
|
|
|
|
glxPixmap->target,
|
|
|
|
glxPixmap->format, drawable->driDrawable);
|
|
|
|
}
|
|
|
|
else
|
2011-11-05 07:32:40 -06:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
texBuffer->setTexBuffer(context->driContext,
|
|
|
|
glxPixmap->target, drawable->driDrawable);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIreleaseTexImage(__GLXcontext * baseContext,
|
|
|
|
int buffer, __GLXdrawable * pixmap)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
/* FIXME: Just unbind the texture? */
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
|
|
|
|
__glXDRIbindTexImage,
|
|
|
|
__glXDRIreleaseTexImage
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIscreenDestroy(__GLXscreen * baseScreen)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->core->destroyScreen) (screen->driScreen);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
dlclose(screen->driver);
|
|
|
|
|
|
|
|
__glXScreenDestroy(baseScreen);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (screen->driConfigs) {
|
|
|
|
for (i = 0; screen->driConfigs[i] != NULL; i++)
|
|
|
|
free((__DRIconfig **) screen->driConfigs[i]);
|
|
|
|
free(screen->driConfigs);
|
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(screen);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static __GLXcontext *
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIscreenCreateContext(__GLXscreen * baseScreen,
|
|
|
|
__GLXconfig * glxConfig,
|
2013-06-07 11:28:45 -06:00
|
|
|
__GLXcontext * baseShareContext,
|
|
|
|
unsigned num_attribs,
|
|
|
|
const uint32_t *attribs,
|
|
|
|
int *error)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
|
|
|
|
__GLXDRIcontext *context, *shareContext;
|
|
|
|
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
|
|
|
|
const __DRIcoreExtension *core = screen->core;
|
|
|
|
__DRIcontext *driShare;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
/* DRISWRAST won't support createContextAttribs, so these parameters will
|
|
|
|
* never be used.
|
|
|
|
*/
|
|
|
|
(void) num_attribs;
|
|
|
|
(void) attribs;
|
|
|
|
(void) error;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
shareContext = (__GLXDRIcontext *) baseShareContext;
|
|
|
|
if (shareContext)
|
2012-06-10 07:21:05 -06:00
|
|
|
driShare = shareContext->driContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
driShare = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
context = calloc(1, sizeof *context);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (context == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
context->base.destroy = __glXDRIcontextDestroy;
|
|
|
|
context->base.makeCurrent = __glXDRIcontextMakeCurrent;
|
|
|
|
context->base.loseCurrent = __glXDRIcontextLoseCurrent;
|
|
|
|
context->base.copy = __glXDRIcontextCopy;
|
2008-11-02 08:26:08 -07:00
|
|
|
context->base.textureFromPixmap = &__glXDRItextureFromPixmap;
|
|
|
|
|
|
|
|
context->driContext =
|
2012-06-10 07:21:05 -06:00
|
|
|
(*core->createNewContext) (screen->driScreen,
|
|
|
|
config->driConfig, driShare, context);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
return &context->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __GLXdrawable *
|
2010-07-27 13:02:24 -06:00
|
|
|
__glXDRIscreenCreateDrawable(ClientPtr client,
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXscreen * screen,
|
|
|
|
DrawablePtr pDraw,
|
|
|
|
XID drawId,
|
|
|
|
int type, XID glxDrawId, __GLXconfig * glxConfig)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2011-11-05 07:32:40 -06:00
|
|
|
XID gcvals[2];
|
|
|
|
int status;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen;
|
|
|
|
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
|
|
|
|
__GLXDRIdrawable *private;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
private = calloc(1, sizeof *private);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (private == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
private->screen = driScreen;
|
|
|
|
if (!__glXDrawableInit(&private->base, screen,
|
2012-06-10 07:21:05 -06:00
|
|
|
pDraw, type, glxDrawId, glxConfig)) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(private);
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
private->base.destroy = __glXDRIdrawableDestroy;
|
|
|
|
private->base.swapBuffers = __glXDRIdrawableSwapBuffers;
|
2008-11-02 08:26:08 -07:00
|
|
|
private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
gcvals[0] = GXcopy;
|
2012-06-10 07:21:05 -06:00
|
|
|
private->gc =
|
|
|
|
CreateGC(pDraw, GCFunction, gcvals, &status, (XID) 0, serverClient);
|
2011-11-05 07:32:40 -06:00
|
|
|
gcvals[1] = FALSE;
|
2012-06-10 07:21:05 -06:00
|
|
|
private->swapgc =
|
|
|
|
CreateGC(pDraw, GCFunction | GCGraphicsExposures, gcvals, &status,
|
|
|
|
(XID) 0, serverClient);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
private->driDrawable =
|
2012-06-10 07:21:05 -06:00
|
|
|
(*driScreen->swrast->createNewDrawable) (driScreen->driScreen,
|
|
|
|
config->driConfig, private);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
return &private->base;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
swrastGetDrawableInfo(__DRIdrawable * draw,
|
|
|
|
int *x, int *y, int *w, int *h, void *loaderPrivate)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *drawable = loaderPrivate;
|
|
|
|
DrawablePtr pDraw = drawable->base.pDraw;
|
|
|
|
|
|
|
|
*x = pDraw->x;
|
|
|
|
*y = pDraw->x;
|
|
|
|
*w = pDraw->width;
|
|
|
|
*h = pDraw->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
swrastPutImage(__DRIdrawable * draw, int op,
|
|
|
|
int x, int y, int w, int h, char *data, void *loaderPrivate)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *drawable = loaderPrivate;
|
|
|
|
DrawablePtr pDraw = drawable->base.pDraw;
|
|
|
|
GCPtr gc;
|
2014-09-27 11:52:59 -06:00
|
|
|
__GLXcontext *cx = lastGLContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case __DRI_SWRAST_IMAGE_OP_DRAW:
|
2012-06-10 07:21:05 -06:00
|
|
|
gc = drawable->gc;
|
|
|
|
break;
|
2008-11-02 08:26:08 -07:00
|
|
|
case __DRI_SWRAST_IMAGE_OP_SWAP:
|
2012-06-10 07:21:05 -06:00
|
|
|
gc = drawable->swapgc;
|
|
|
|
break;
|
2008-11-02 08:26:08 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ValidateGC(pDraw, gc);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
gc->ops->PutImage(pDraw, gc, pDraw->depth, x, y, w, h, 0, ZPixmap, data);
|
2014-09-27 11:52:59 -06:00
|
|
|
if (cx != lastGLContext) {
|
|
|
|
lastGLContext = cx;
|
|
|
|
cx->makeCurrent(cx);
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
swrastGetImage(__DRIdrawable * draw,
|
|
|
|
int x, int y, int w, int h, char *data, void *loaderPrivate)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *drawable = loaderPrivate;
|
|
|
|
DrawablePtr pDraw = drawable->base.pDraw;
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
2014-09-27 11:52:59 -06:00
|
|
|
__GLXcontext *cx = lastGLContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
pScreen->GetImage(pDraw, x, y, w, h, ZPixmap, ~0L, data);
|
2014-09-27 11:52:59 -06:00
|
|
|
if (cx != lastGLContext) {
|
|
|
|
lastGLContext = cx;
|
|
|
|
cx->makeCurrent(cx);
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static const __DRIswrastLoaderExtension swrastLoaderExtension = {
|
2014-05-02 13:27:46 -06:00
|
|
|
{__DRI_SWRAST_LOADER, 1},
|
2008-11-02 08:26:08 -07:00
|
|
|
swrastGetDrawableInfo,
|
|
|
|
swrastPutImage,
|
|
|
|
swrastGetImage
|
|
|
|
};
|
|
|
|
|
|
|
|
static const __DRIextension *loader_extensions[] = {
|
|
|
|
&systemTimeExtension.base,
|
|
|
|
&swrastLoaderExtension.base,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
initializeExtensions(__GLXDRIscreen * screen)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
const __DRIextension **extensions;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
extensions = screen->core->getExtensions(screen->driScreen);
|
|
|
|
|
|
|
|
for (i = 0; extensions[i]; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
|
|
|
|
screen->copySubBuffer =
|
|
|
|
(const __DRIcopySubBufferExtension *) extensions[i];
|
|
|
|
/* GLX_MESA_copy_sub_buffer is always enabled. */
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
|
|
|
|
screen->texBuffer = (const __DRItexBufferExtension *) extensions[i];
|
|
|
|
/* GLX_EXT_texture_from_pixmap is always enabled. */
|
|
|
|
}
|
2014-09-27 11:52:59 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Ignore unknown extensions */
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
/* white lie */
|
|
|
|
extern glx_func_ptr glXGetProcAddressARB(const char *);
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
static __GLXscreen *
|
|
|
|
__glXDRIscreenProbe(ScreenPtr pScreen)
|
|
|
|
{
|
2013-09-09 08:51:24 -06:00
|
|
|
const char *driverName = "swrast";
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
screen = calloc(1, sizeof *screen);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->base.destroy = __glXDRIscreenDestroy;
|
|
|
|
screen->base.createContext = __glXDRIscreenCreateContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
screen->base.createDrawable = __glXDRIscreenCreateDrawable;
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->base.swapInterval = NULL;
|
|
|
|
screen->base.pScreen = pScreen;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
screen->driver = glxProbeDriver(driverName,
|
2012-06-10 07:21:05 -06:00
|
|
|
(void **) &screen->core,
|
2014-05-02 13:27:46 -06:00
|
|
|
__DRI_CORE, 1,
|
2012-06-10 07:21:05 -06:00
|
|
|
(void **) &screen->swrast,
|
2014-05-02 13:27:46 -06:00
|
|
|
__DRI_SWRAST, 1);
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->driver == NULL) {
|
|
|
|
goto handle_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
screen->driScreen =
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->swrast->createNewScreen) (pScreen->myNum,
|
|
|
|
loader_extensions,
|
|
|
|
&screen->driConfigs, screen);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (screen->driScreen == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_ERROR, "AIGLX error: Calling driver entry point failed\n");
|
|
|
|
goto handle_error;
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
initializeExtensions(screen);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->base.fbconfigs = glxConvertConfigs(screen->core, screen->driConfigs,
|
|
|
|
GLX_WINDOW_BIT |
|
|
|
|
GLX_PIXMAP_BIT |
|
|
|
|
GLX_PBUFFER_BIT);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
__glXScreenInit(&screen->base, pScreen);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
screen->base.GLXmajor = 1;
|
|
|
|
screen->base.GLXminor = 4;
|
|
|
|
|
2014-05-02 13:27:46 -06:00
|
|
|
__glXsetGetProcAddress(glXGetProcAddressARB);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_INFO, "AIGLX: Loaded and initialized %s\n", driverName);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
return &screen->base;
|
|
|
|
|
|
|
|
handle_error:
|
|
|
|
if (screen->driver)
|
|
|
|
dlclose(screen->driver);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(screen);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
LogMessage(X_ERROR, "GLX: could not load software renderer\n");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
_X_EXPORT __GLXprovider __glXDRISWRastProvider = {
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXDRIscreenProbe,
|
|
|
|
"DRISWRAST",
|
|
|
|
NULL
|
|
|
|
};
|