2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* 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>
|
2010-12-05 08:36:02 -07:00
|
|
|
#include <GL/glxtokens.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#include <windowstr.h>
|
|
|
|
#include <os.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <damage.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define _XF86DRI_SERVER_
|
|
|
|
#include <drm_sarea.h>
|
|
|
|
#include <xf86drm.h>
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <X11/dri/xf86driproto.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include <xf86str.h>
|
|
|
|
#include <xf86.h>
|
|
|
|
#include <dri.h>
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "servermd.h"
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#define DRI_NEW_INTERFACE_ONLY
|
|
|
|
#include "glxserver.h"
|
|
|
|
#include "glxutil.h"
|
2008-11-02 08:26:08 -07:00
|
|
|
#include "glxdricommon.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#include "glapitable.h"
|
|
|
|
#include "glapi.h"
|
|
|
|
#include "glthread.h"
|
|
|
|
#include "dispatch.h"
|
|
|
|
#include "extension_string.h"
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef struct __GLXDRIscreen __GLXDRIscreen;
|
|
|
|
typedef struct __GLXDRIcontext __GLXDRIcontext;
|
2006-11-26 11:13:41 -07:00
|
|
|
typedef struct __GLXDRIdrawable __GLXDRIdrawable;
|
|
|
|
|
|
|
|
struct __GLXDRIscreen {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXscreen base;
|
|
|
|
__DRIscreen *driScreen;
|
|
|
|
void *driver;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
xf86EnterVTProc *enterVT;
|
|
|
|
xf86LeaveVTProc *leaveVT;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
const __DRIcoreExtension *core;
|
|
|
|
const __DRIlegacyExtension *legacy;
|
|
|
|
const __DRIcopySubBufferExtension *copySubBuffer;
|
|
|
|
const __DRIswapControlExtension *swapControl;
|
2012-06-10 07:21:05 -06:00
|
|
|
const __DRIconfig **driConfigs;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#ifdef __DRI_TEX_OFFSET
|
|
|
|
const __DRItexOffsetExtension *texOffset;
|
2007-11-24 10:55:21 -07:00
|
|
|
DRITexOffsetStartProcPtr texOffsetStart;
|
|
|
|
DRITexOffsetFinishProcPtr texOffsetFinish;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIdrawable *texOffsetOverride[16];
|
2007-11-24 10:55:21 -07:00
|
|
|
GLuint lastTexOffsetOverride;
|
2008-11-02 08:26:08 -07:00
|
|
|
#endif
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned char glx_enable_bits[__GLX_EXT_BYTES];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct __GLXDRIcontext {
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXcontext base;
|
|
|
|
__DRIcontext *driContext;
|
|
|
|
XID hwContextID;
|
2006-11-26 11:13:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct __GLXDRIdrawable {
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXdrawable base;
|
|
|
|
__DRIdrawable *driDrawable;
|
|
|
|
|
|
|
|
/* Pulled in from old __GLXpixmap */
|
|
|
|
#ifdef __DRI_TEX_OFFSET
|
|
|
|
GLint texname;
|
|
|
|
__GLXDRIcontext *ctx;
|
2009-09-06 13:44:18 -06:00
|
|
|
unsigned long long offset;
|
2008-11-02 08:26:08 -07:00
|
|
|
DamagePtr pDamage;
|
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2007-11-24 10:55:21 -07:00
|
|
|
__glXDRIleaveServer(GLboolean rendering)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; rendering && i < screenInfo.numScreens; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXDRIscreen *const screen =
|
|
|
|
(__GLXDRIscreen *) glxGetScreen(screenInfo.screens[i]);
|
|
|
|
GLuint lastOverride = screen->lastTexOffsetOverride;
|
|
|
|
|
|
|
|
if (lastOverride) {
|
|
|
|
__GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < lastOverride; j++) {
|
|
|
|
__GLXDRIdrawable *pGlxPix = texOffsetOverride[j];
|
|
|
|
|
|
|
|
if (pGlxPix && pGlxPix->texname) {
|
|
|
|
pGlxPix->offset =
|
|
|
|
screen->texOffsetStart((PixmapPtr) pGlxPix->base.pDraw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DRIBlockHandler(NULL, NULL, NULL);
|
|
|
|
|
|
|
|
for (i = 0; rendering && i < screenInfo.numScreens; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXDRIscreen *const screen =
|
|
|
|
(__GLXDRIscreen *) glxGetScreen(screenInfo.screens[i]);
|
|
|
|
GLuint lastOverride = screen->lastTexOffsetOverride;
|
|
|
|
|
|
|
|
if (lastOverride) {
|
|
|
|
__GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < lastOverride; j++) {
|
|
|
|
__GLXDRIdrawable *pGlxPix = texOffsetOverride[j];
|
|
|
|
|
|
|
|
if (pGlxPix && pGlxPix->texname) {
|
|
|
|
screen->texOffset->setTexOffset(pGlxPix->ctx->driContext,
|
|
|
|
pGlxPix->texname,
|
|
|
|
pGlxPix->offset,
|
|
|
|
pGlxPix->base.pDraw->depth,
|
|
|
|
((PixmapPtr) pGlxPix->base.
|
|
|
|
pDraw)->devKind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
static void
|
2007-11-24 10:55:21 -07:00
|
|
|
__glXDRIenterServer(GLboolean rendering)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; rendering && i < screenInfo.numScreens; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXDRIscreen *const screen = (__GLXDRIscreen *)
|
|
|
|
glxGetScreen(screenInfo.screens[i]);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (screen->lastTexOffsetOverride) {
|
|
|
|
CALL_Flush(GET_DISPATCH(), ());
|
|
|
|
break;
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DRIWakeupHandler(NULL, 0, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdoReleaseTexImage(__GLXDRIscreen * screen, __GLXDRIdrawable * drawable)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
GLuint lastOverride = screen->lastTexOffsetOverride;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (lastOverride) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride;
|
|
|
|
int i;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < lastOverride; i++) {
|
|
|
|
if (texOffsetOverride[i] == drawable) {
|
|
|
|
if (screen->texOffsetFinish)
|
|
|
|
screen->texOffsetFinish((PixmapPtr) drawable->base.pDraw);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
texOffsetOverride[i] = NULL;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (i + 1 == lastOverride) {
|
|
|
|
lastOverride = 0;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
while (i--) {
|
|
|
|
if (texOffsetOverride[i]) {
|
|
|
|
lastOverride = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->lastTexOffsetOverride = lastOverride;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdrawableDestroy(__GLXdrawable * drawable)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
|
|
|
|
__GLXDRIscreen *screen;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < screenInfo.numScreens; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
screen = (__GLXDRIscreen *) glxGetScreen(screenInfo.screens[i]);
|
|
|
|
__glXDRIdoReleaseTexImage(screen, private);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If the X window was destroyed, the dri DestroyWindow hook will
|
|
|
|
* aready have taken care of this, so only call if pDraw isn't NULL. */
|
|
|
|
if (drawable->pDraw != NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
screen = (__GLXDRIscreen *) glxGetScreen(drawable->pDraw->pScreen);
|
|
|
|
(*screen->core->destroyDrawable) (private->driDrawable);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
DRIDestroyDrawable(drawable->pDraw->pScreen,
|
|
|
|
serverClient, drawable->pDraw);
|
|
|
|
__glXleaveServer(GL_FALSE);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
__glXDrawableRelease(drawable);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(private);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static GLboolean
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdrawableSwapBuffers(ClientPtr client, __GLXdrawable * basePrivate)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen =
|
2012-06-10 07:21:05 -06:00
|
|
|
(__GLXDRIscreen *) glxGetScreen(basePrivate->pDraw->pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->core->swapBuffers) (private->driDrawable);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdrawableSwapInterval(__GLXdrawable * baseDrawable, int interval)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *draw = (__GLXDRIdrawable *) baseDrawable;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen =
|
2012-06-10 07:21:05 -06:00
|
|
|
(__GLXDRIscreen *) glxGetScreen(baseDrawable->pDraw->pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->swapControl)
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->swapControl->setSwapInterval(draw->driDrawable, interval);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIdrawableCopySubBuffer(__GLXdrawable * basePrivate,
|
|
|
|
int x, int y, int w, int h)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *)
|
2012-06-10 07:21:05 -06:00
|
|
|
glxGetScreen(basePrivate->pDraw->pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (screen->copySubBuffer)
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->copySubBuffer->copySubBuffer(private->driDrawable, x, y, w, h);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextDestroy(__GLXcontext * baseContext)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
|
|
|
|
Bool retval;
|
|
|
|
|
|
|
|
screen->core->destroyContext(context->driContext);
|
|
|
|
|
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
retval = DRIDestroyContext(baseContext->pGlxScreen->pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
context->hwContextID);
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXleaveServer(GL_FALSE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
__glXContextDestroy(&context->base);
|
2010-12-05 08:36:02 -07:00
|
|
|
free(context);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextMakeCurrent(__GLXcontext * baseContext)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
|
|
|
|
__GLXDRIdrawable *draw = (__GLXDRIdrawable *) baseContext->drawPriv;
|
|
|
|
__GLXDRIdrawable *read = (__GLXDRIdrawable *) baseContext->readPriv;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*screen->core->bindContext) (context->driContext,
|
|
|
|
draw->driDrawable, read->driDrawable);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextLoseCurrent(__GLXcontext * baseContext)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *context = (__GLXDRIcontext *) baseContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*screen->core->unbindContext) (context->driContext);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIcontextCopy(__GLXcontext * baseDst, __GLXcontext * baseSrc,
|
|
|
|
unsigned long mask)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIcontext *dst = (__GLXDRIcontext *) baseDst;
|
|
|
|
__GLXDRIcontext *src = (__GLXDRIcontext *) baseSrc;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) dst->base.pGlxScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
return (*screen->core->copyContext) (dst->driContext,
|
|
|
|
src->driContext, mask);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
glxFillAlphaChannel(CARD32 *pixels, CARD32 rowstride, int width, int height)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int i;
|
2008-11-02 08:26:08 -07:00
|
|
|
CARD32 *p, *end;
|
|
|
|
|
|
|
|
rowstride /= 4;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
for (i = 0; i < height; i++) {
|
|
|
|
p = pixels;
|
|
|
|
end = p + width;
|
|
|
|
while (p < end)
|
|
|
|
*p++ |= 0xFF000000;
|
|
|
|
pixels += rowstride;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
static Bool
|
|
|
|
testTexOffset(__GLXDRIscreen * const screen, PixmapPtr pPixmap)
|
|
|
|
{
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
if (!screen->texOffsetStart || !screen->texOffset)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
ret = screen->texOffsetStart(pPixmap) != ~0ULL;
|
|
|
|
__glXleaveServer(GL_FALSE);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* (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 support for anything but 16bpp and 32bpp-sparse pixmaps
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIbindTexImage(__GLXcontext * baseContext,
|
|
|
|
int buffer, __GLXdrawable * glxPixmap)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr pRegion = NULL;
|
|
|
|
PixmapPtr pixmap;
|
|
|
|
int bpp, override = 0, texname;
|
|
|
|
GLenum format, type;
|
2008-11-02 08:26:08 -07:00
|
|
|
ScreenPtr pScreen = glxPixmap->pDraw->pScreen;
|
|
|
|
__GLXDRIdrawable *driDraw = (__GLXDRIdrawable *) glxPixmap;
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXDRIscreen *const screen = (__GLXDRIscreen *) glxGetScreen(pScreen);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
CALL_GetIntegerv(GET_DISPATCH(), (glxPixmap->target == GL_TEXTURE_2D ?
|
2012-06-10 07:21:05 -06:00
|
|
|
GL_TEXTURE_BINDING_2D :
|
|
|
|
GL_TEXTURE_BINDING_RECTANGLE_NV,
|
|
|
|
&texname));
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (!texname)
|
2012-06-10 07:21:05 -06:00
|
|
|
return __glXError(GLXBadContextState);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pixmap = (PixmapPtr) glxPixmap->pDraw;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (testTexOffset(screen, pixmap)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__GLXDRIdrawable **texOffsetOverride = screen->texOffsetOverride;
|
|
|
|
int i, firstEmpty = 16;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
if (texOffsetOverride[i] == driDraw)
|
|
|
|
goto alreadyin;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (firstEmpty == 16 && !texOffsetOverride[i])
|
|
|
|
firstEmpty = i;
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (firstEmpty == 16) {
|
|
|
|
ErrorF("%s: Failed to register texture offset override\n",
|
|
|
|
__func__);
|
|
|
|
goto nooverride;
|
|
|
|
}
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (firstEmpty >= screen->lastTexOffsetOverride)
|
|
|
|
screen->lastTexOffsetOverride = firstEmpty + 1;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
texOffsetOverride[firstEmpty] = driDraw;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
alreadyin:
|
|
|
|
override = 1;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
driDraw->ctx = (__GLXDRIcontext *) baseContext;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (texname == driDraw->texname)
|
|
|
|
return Success;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
driDraw->texname = texname;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->texOffset->setTexOffset(driDraw->ctx->driContext, texname, 0,
|
|
|
|
pixmap->drawable.depth,
|
|
|
|
pixmap->devKind);
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
nooverride:
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!driDraw->pDamage) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!override) {
|
|
|
|
driDraw->pDamage = DamageCreate(NULL, NULL, DamageReportNone,
|
|
|
|
TRUE, pScreen, NULL);
|
|
|
|
if (!driDraw->pDamage)
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
DamageRegister((DrawablePtr) pixmap, driDraw->pDamage);
|
|
|
|
}
|
|
|
|
|
|
|
|
pRegion = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pRegion = DamageRegion(driDraw->pDamage);
|
|
|
|
if (RegionNil(pRegion))
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX 24bpp packed, 8, etc */
|
|
|
|
if (pixmap->drawable.depth >= 24) {
|
2012-06-10 07:21:05 -06:00
|
|
|
bpp = 4;
|
|
|
|
format = GL_BGRA;
|
|
|
|
type =
|
2007-11-24 10:55:21 -07:00
|
|
|
#if X_BYTE_ORDER == X_BIG_ENDIAN
|
2012-06-10 07:21:05 -06:00
|
|
|
!override ? GL_UNSIGNED_INT_8_8_8_8_REV :
|
2006-11-26 11:13:41 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
GL_UNSIGNED_BYTE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bpp = 2;
|
|
|
|
format = GL_RGB;
|
|
|
|
type = GL_UNSIGNED_SHORT_5_6_5;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (pRegion == NULL) {
|
|
|
|
void *data = NULL;
|
|
|
|
|
|
|
|
if (!override) {
|
|
|
|
unsigned pitch = PixmapBytePad(pixmap->drawable.width,
|
|
|
|
pixmap->drawable.depth);
|
|
|
|
|
|
|
|
data = malloc(pitch * pixmap->drawable.height);
|
|
|
|
|
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
pScreen->GetImage(&pixmap->drawable, 0 /*pixmap->drawable.x */ ,
|
|
|
|
0 /*pixmap->drawable.y */ ,
|
|
|
|
pixmap->drawable.width,
|
|
|
|
pixmap->drawable.height, ZPixmap, ~0, data);
|
|
|
|
__glXleaveServer(GL_FALSE);
|
|
|
|
|
|
|
|
if (pixmap->drawable.depth == 24)
|
|
|
|
glxFillAlphaChannel(data,
|
|
|
|
pitch,
|
|
|
|
pixmap->drawable.width,
|
|
|
|
pixmap->drawable.height);
|
|
|
|
|
|
|
|
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,
|
|
|
|
pitch / bpp));
|
|
|
|
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, 0));
|
|
|
|
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
CALL_TexImage2D(GET_DISPATCH(),
|
|
|
|
(glxPixmap->target,
|
|
|
|
0,
|
|
|
|
bpp == 4 ? 4 : 3,
|
|
|
|
pixmap->drawable.width,
|
|
|
|
pixmap->drawable.height, 0, format, type, data));
|
|
|
|
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
else if (!override) {
|
2006-11-26 11:13:41 -07:00
|
|
|
int i, numRects;
|
2012-06-10 07:21:05 -06:00
|
|
|
BoxPtr p;
|
|
|
|
|
|
|
|
numRects = RegionNumRects(pRegion);
|
|
|
|
p = RegionRects(pRegion);
|
|
|
|
|
|
|
|
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS, 0));
|
|
|
|
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS, 0));
|
|
|
|
|
|
|
|
for (i = 0; i < numRects; i++) {
|
|
|
|
unsigned pitch = PixmapBytePad(p[i].x2 - p[i].x1,
|
|
|
|
pixmap->drawable.depth);
|
|
|
|
void *data = malloc(pitch * (p[i].y2 - p[i].y1));
|
|
|
|
|
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
pScreen->GetImage(&pixmap->drawable, /*pixmap->drawable.x + */
|
|
|
|
p[i].x1,
|
|
|
|
/*pixmap->drawable.y */ +p[i].y1,
|
|
|
|
p[i].x2 - p[i].x1,
|
|
|
|
p[i].y2 - p[i].y1, ZPixmap, ~0, data);
|
|
|
|
__glXleaveServer(GL_FALSE);
|
|
|
|
|
|
|
|
if (pixmap->drawable.depth == 24)
|
|
|
|
glxFillAlphaChannel(data,
|
|
|
|
pitch,
|
|
|
|
p[i].x2 - p[i].x1, p[i].y2 - p[i].y1);
|
|
|
|
|
|
|
|
CALL_PixelStorei(GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,
|
|
|
|
pitch / bpp));
|
|
|
|
|
|
|
|
CALL_TexSubImage2D(GET_DISPATCH(),
|
|
|
|
(glxPixmap->target,
|
|
|
|
0,
|
|
|
|
p[i].x1, p[i].y1,
|
|
|
|
p[i].x2 - p[i].x1, p[i].y2 - p[i].y1,
|
|
|
|
format, type, data));
|
|
|
|
|
|
|
|
free(data);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!override)
|
2012-06-10 07:21:05 -06:00
|
|
|
DamageEmpty(driDraw->pDamage);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIreleaseTexImage(__GLXcontext * baseContext,
|
|
|
|
int buffer, __GLXdrawable * pixmap)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen =
|
2012-06-10 07:21:05 -06:00
|
|
|
(__GLXDRIscreen *) glxGetScreen(pixmap->pDraw->pScreen);
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIdrawable *drawable = (__GLXDRIdrawable *) pixmap;
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXDRIdoReleaseTexImage(screen, drawable);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
|
|
|
|
__glXDRIbindTexImage,
|
|
|
|
__glXDRIreleaseTexImage
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXDRIscreenDestroy(__GLXscreen * baseScreen)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
screen->core->destroyScreen(screen->driScreen);
|
2006-11-26 11:13:41 -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);
|
2006-11-26 11:13:41 -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)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
|
|
|
|
__GLXDRIcontext *context, *shareContext;
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
|
|
|
|
VisualPtr visual;
|
|
|
|
int i;
|
|
|
|
GLboolean retval;
|
|
|
|
__DRIcontext *driShare;
|
|
|
|
drm_context_t hwContext;
|
|
|
|
ScreenPtr pScreen = baseScreen->pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
/* DRI1 cannot support createContextAttribs, so these parameters will
|
|
|
|
* never be used.
|
|
|
|
*/
|
|
|
|
(void) num_attribs;
|
|
|
|
(void) attribs;
|
|
|
|
(void) error;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
shareContext = (__GLXDRIcontext *) baseShareContext;
|
|
|
|
if (shareContext)
|
2012-06-10 07:21:05 -06:00
|
|
|
driShare = shareContext->driContext;
|
2006-11-26 11:13:41 -07:00
|
|
|
else
|
2012-06-10 07:21:05 -06:00
|
|
|
driShare = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-06-14 18:17:32 -06:00
|
|
|
if (baseShareContext && baseShareContext->isDirect)
|
|
|
|
return NULL;
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
context = calloc(1, sizeof *context);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (context == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -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;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
context->base.textureFromPixmap = &__glXDRItextureFromPixmap;
|
2008-11-02 08:26:08 -07:00
|
|
|
/* Find the requested X visual */
|
|
|
|
visual = pScreen->visuals;
|
|
|
|
for (i = 0; i < pScreen->numVisuals; i++, visual++)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (visual->vid == glxConfig->visualID)
|
|
|
|
break;
|
2008-11-02 08:26:08 -07:00
|
|
|
if (i == pScreen->numVisuals)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
context->hwContextID = FakeClientID(0);
|
|
|
|
|
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
retval = DRICreateContext(baseScreen->pScreen, visual,
|
2012-06-10 07:21:05 -06:00
|
|
|
context->hwContextID, &hwContext);
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXleaveServer(GL_FALSE);
|
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!retval)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
context->driContext = screen->legacy->createNewContext(screen->driScreen, config->driConfig, 0, /* render type */
|
|
|
|
driShare,
|
|
|
|
hwContext, context);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (context->driContext == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
retval = DRIDestroyContext(baseScreen->pScreen, context->hwContextID);
|
|
|
|
__glXleaveServer(GL_FALSE);
|
|
|
|
free(context);
|
|
|
|
return NULL;
|
2008-06-14 18:17:32 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -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)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen;
|
|
|
|
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
|
2006-11-26 11:13:41 -07:00
|
|
|
__GLXDRIdrawable *private;
|
2008-11-02 08:26:08 -07:00
|
|
|
GLboolean retval;
|
|
|
|
drm_drawable_t hwDrawable;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
private = calloc(1, sizeof *private);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (private == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
private->base.destroy = __glXDRIdrawableDestroy;
|
|
|
|
private->base.swapBuffers = __glXDRIdrawableSwapBuffers;
|
2006-11-26 11:13:41 -07:00
|
|
|
private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer;
|
2012-06-10 07:21:05 -06:00
|
|
|
private->base.waitX = NULL;
|
|
|
|
private->base.waitGL = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
retval = DRICreateDrawable(screen->pScreen, serverClient,
|
2012-06-10 07:21:05 -06:00
|
|
|
pDraw, &hwDrawable);
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXleaveServer(GL_FALSE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (!retval) {
|
2010-12-05 08:36:02 -07:00
|
|
|
free(private);
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2009-09-06 13:44:18 -06:00
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/* The last argument is 'attrs', which is used with pbuffers which
|
|
|
|
* we currently don't support. */
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
private->driDrawable =
|
2012-06-10 07:21:05 -06:00
|
|
|
(driScreen->legacy->createNewDrawable) (driScreen->driScreen,
|
|
|
|
config->driConfig,
|
|
|
|
hwDrawable, 0, NULL, private);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (private->driDrawable == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
DRIDestroyDrawable(screen->pScreen, serverClient, pDraw);
|
|
|
|
__glXleaveServer(GL_FALSE);
|
|
|
|
free(private);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
return &private->base;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static GLboolean
|
2012-06-10 07:21:05 -06:00
|
|
|
getDrawableInfo(__DRIdrawable * driDrawable,
|
|
|
|
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,
|
|
|
|
void *data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIdrawable *drawable = data;
|
|
|
|
ScreenPtr pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
drm_clip_rect_t *pClipRects, *pBackClipRects;
|
|
|
|
GLboolean retval;
|
|
|
|
size_t size;
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/* If the X window has been destroyed, give up here. */
|
|
|
|
if (drawable->base.pDraw == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return GL_FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
pScreen = drawable->base.pDraw->pScreen;
|
|
|
|
__glXenterServer(GL_FALSE);
|
|
|
|
retval = DRIGetDrawableInfo(pScreen, drawable->base.pDraw, index, stamp,
|
2012-06-10 07:21:05 -06:00
|
|
|
x, y, width, height,
|
|
|
|
numClipRects, &pClipRects,
|
|
|
|
backX, backY,
|
|
|
|
numBackClipRects, &pBackClipRects);
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXleaveServer(GL_FALSE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (retval && *numClipRects > 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
size = sizeof(drm_clip_rect_t) * *numClipRects;
|
|
|
|
*ppClipRects = malloc(size);
|
|
|
|
|
|
|
|
/* Clip cliprects to screen dimensions (redirected windows) */
|
|
|
|
if (*ppClipRects != NULL) {
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < *numClipRects; i++) {
|
|
|
|
(*ppClipRects)[j].x1 = max(pClipRects[i].x1, 0);
|
|
|
|
(*ppClipRects)[j].y1 = max(pClipRects[i].y1, 0);
|
|
|
|
(*ppClipRects)[j].x2 = min(pClipRects[i].x2, pScreen->width);
|
|
|
|
(*ppClipRects)[j].y2 = min(pClipRects[i].y2, pScreen->height);
|
|
|
|
|
|
|
|
if ((*ppClipRects)[j].x1 < (*ppClipRects)[j].x2 &&
|
|
|
|
(*ppClipRects)[j].y1 < (*ppClipRects)[j].y2) {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*numClipRects != j) {
|
|
|
|
*numClipRects = j;
|
|
|
|
*ppClipRects = realloc(*ppClipRects,
|
|
|
|
sizeof(drm_clip_rect_t) * *numClipRects);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*numClipRects = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
*ppClipRects = NULL;
|
|
|
|
*numClipRects = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (retval && *numBackClipRects > 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
size = sizeof(drm_clip_rect_t) * *numBackClipRects;
|
|
|
|
*ppBackClipRects = malloc(size);
|
|
|
|
if (*ppBackClipRects != NULL)
|
|
|
|
memcpy(*ppBackClipRects, pBackClipRects, size);
|
|
|
|
else
|
|
|
|
*numBackClipRects = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
*ppBackClipRects = NULL;
|
|
|
|
*numBackClipRects = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
return retval;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
__glXReportDamage(__DRIdrawable * driDraw,
|
|
|
|
int x, int y,
|
|
|
|
drm_clip_rect_t * rects, int num_rects,
|
|
|
|
GLboolean front_buffer, void *data)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIdrawable *drawable = data;
|
|
|
|
DrawablePtr pDraw = drawable->base.pDraw;
|
|
|
|
RegionRec region;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXenterServer(GL_FALSE);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
if (RegionInitBoxes(®ion, (BoxPtr) rects, num_rects)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionTranslate(®ion, pDraw->x, pDraw->y);
|
|
|
|
DamageDamageRegion(pDraw, ®ion);
|
|
|
|
RegionUninit(®ion);
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
while (num_rects--) {
|
|
|
|
RegionInit(®ion, (BoxPtr) rects++, 1);
|
|
|
|
RegionTranslate(®ion, pDraw->x, pDraw->y);
|
|
|
|
DamageDamageRegion(pDraw, ®ion);
|
|
|
|
RegionUninit(®ion);
|
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXleaveServer(GL_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = {
|
2012-06-10 07:21:05 -06:00
|
|
|
{__DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION},
|
2008-11-02 08:26:08 -07:00
|
|
|
getDrawableInfo
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
static const __DRIdamageExtension damageExtension = {
|
2012-06-10 07:21:05 -06:00
|
|
|
{__DRI_DAMAGE, __DRI_DAMAGE_VERSION},
|
2008-11-02 08:26:08 -07:00
|
|
|
__glXReportDamage,
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
static const __DRIextension *loader_extensions[] = {
|
|
|
|
&systemTimeExtension.base,
|
|
|
|
&getDrawableInfoExtension.base,
|
|
|
|
&damageExtension.base,
|
|
|
|
NULL
|
2006-11-26 11:13:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static Bool
|
2013-06-07 11:28:45 -06:00
|
|
|
glxDRIEnterVT(ScrnInfoPtr scrn)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool ret;
|
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *)
|
2013-06-07 11:28:45 -06:00
|
|
|
glxGetScreen(xf86ScrnToScreen(scrn));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
LogMessage(X_INFO, "AIGLX: Resuming AIGLX clients after VT switch\n");
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
scrn->EnterVT = screen->enterVT;
|
|
|
|
|
2013-06-07 11:28:45 -06:00
|
|
|
ret = scrn->EnterVT(scrn);
|
2010-12-05 08:36:02 -07:00
|
|
|
|
|
|
|
screen->enterVT = scrn->EnterVT;
|
|
|
|
scrn->EnterVT = glxDRIEnterVT;
|
|
|
|
|
|
|
|
if (!ret)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
glxResumeClients();
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-06-07 11:28:45 -06:00
|
|
|
glxDRILeaveVT(ScrnInfoPtr scrn)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
__GLXDRIscreen *screen = (__GLXDRIscreen *)
|
2013-06-07 11:28:45 -06:00
|
|
|
glxGetScreen(xf86ScrnToScreen(scrn));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-08-24 13:44:25 -06:00
|
|
|
LogMessageVerbSigSafe(X_INFO, -1, "AIGLX: Suspending AIGLX clients for VT switch\n");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
glxSuspendClients();
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
scrn->LeaveVT = screen->leaveVT;
|
2013-06-07 11:28:45 -06:00
|
|
|
(*screen->leaveVT) (scrn);
|
2010-12-05 08:36:02 -07:00
|
|
|
screen->leaveVT = scrn->LeaveVT;
|
|
|
|
scrn->LeaveVT = glxDRILeaveVT;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
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++) {
|
2009-09-06 13:44:18 -06:00
|
|
|
#ifdef __DRI_READ_DRAWABLE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
|
|
|
|
__glXEnableExtension(screen->glx_enable_bits,
|
|
|
|
"GLX_SGI_make_current_read");
|
|
|
|
|
|
|
|
LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_make_current_read\n");
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
#endif
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
#ifdef __DRI_COPY_SUB_BUFFER
|
2012-06-10 07:21:05 -06:00
|
|
|
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
|
|
|
|
screen->copySubBuffer =
|
|
|
|
(__DRIcopySubBufferExtension *) extensions[i];
|
|
|
|
__glXEnableExtension(screen->glx_enable_bits,
|
|
|
|
"GLX_MESA_copy_sub_buffer");
|
|
|
|
|
|
|
|
LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __DRI_SWAP_CONTROL
|
2012-06-10 07:21:05 -06:00
|
|
|
if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
|
|
|
|
screen->swapControl = (__DRIswapControlExtension *) extensions[i];
|
|
|
|
__glXEnableExtension(screen->glx_enable_bits,
|
|
|
|
"GLX_SGI_swap_control");
|
|
|
|
__glXEnableExtension(screen->glx_enable_bits,
|
|
|
|
"GLX_MESA_swap_control");
|
|
|
|
|
|
|
|
LogMessage(X_INFO,
|
|
|
|
"AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n");
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __DRI_TEX_OFFSET
|
2012-06-10 07:21:05 -06:00
|
|
|
if (strcmp(extensions[i]->name, __DRI_TEX_OFFSET) == 0) {
|
|
|
|
screen->texOffset = (__DRItexOffsetExtension *) extensions[i];
|
|
|
|
LogMessage(X_INFO,
|
|
|
|
"AIGLX: enabled GLX_texture_from_pixmap with driver support\n");
|
|
|
|
}
|
2008-11-02 08:26:08 -07:00
|
|
|
#endif
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Ignore unknown extensions */
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
static __GLXscreen *
|
|
|
|
__glXDRIscreenProbe(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
drm_handle_t hSAREA;
|
|
|
|
drmAddress pSAREA = NULL;
|
|
|
|
char *BusID;
|
2012-06-10 07:21:05 -06:00
|
|
|
__DRIversion ddx_version;
|
|
|
|
__DRIversion dri_version;
|
|
|
|
__DRIversion drm_version;
|
|
|
|
__DRIframebuffer framebuffer;
|
|
|
|
int fd = -1;
|
|
|
|
int status;
|
2006-11-26 11:13:41 -07:00
|
|
|
drm_magic_t magic;
|
|
|
|
drmVersionPtr version;
|
2007-03-03 04:09:19 -07:00
|
|
|
int newlyopened;
|
2006-11-26 11:13:41 -07:00
|
|
|
char *driverName;
|
2012-06-10 07:21:05 -06:00
|
|
|
drm_handle_t hFB;
|
|
|
|
int junk;
|
2006-11-26 11:13:41 -07:00
|
|
|
__GLXDRIscreen *screen;
|
|
|
|
Bool isCapable;
|
|
|
|
size_t buffer_size;
|
2013-06-07 11:28:45 -06:00
|
|
|
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2013-09-28 09:36:30 -06:00
|
|
|
framebuffer.base = NULL;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
if (!xf86LoaderCheckSymbol("DRIQueryDirectRenderingCapable") ||
|
2012-06-10 07:21:05 -06:00
|
|
|
!DRIQueryDirectRenderingCapable(pScreen, &isCapable) || !isCapable) {
|
|
|
|
LogMessage(X_INFO,
|
|
|
|
"AIGLX: Screen %d is not DRI capable\n", pScreen->myNum);
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
screen = calloc(1, sizeof *screen);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (screen == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->base.destroy = __glXDRIscreenDestroy;
|
|
|
|
screen->base.createContext = __glXDRIscreenCreateContext;
|
2006-11-26 11:13:41 -07:00
|
|
|
screen->base.createDrawable = __glXDRIscreenCreateDrawable;
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->base.swapInterval = __glXDRIdrawableSwapInterval;
|
|
|
|
screen->base.pScreen = pScreen;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
__glXInitExtensionEnableBits(screen->glx_enable_bits);
|
|
|
|
|
|
|
|
/* DRI protocol version. */
|
|
|
|
dri_version.major = XF86DRI_MAJOR_VERSION;
|
|
|
|
dri_version.minor = XF86DRI_MINOR_VERSION;
|
|
|
|
dri_version.patch = XF86DRI_PATCH_VERSION;
|
|
|
|
|
|
|
|
if (!DRIOpenConnection(pScreen, &hSAREA, &BusID)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_ERROR, "AIGLX error: DRIOpenConnection failed\n");
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-03-03 04:09:19 -07:00
|
|
|
fd = drmOpenOnce(NULL, BusID, &newlyopened);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (fd < 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_ERROR, "AIGLX error: drmOpenOnce failed (%s)\n",
|
|
|
|
strerror(-fd));
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (drmGetMagic(fd, &magic)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_ERROR, "AIGLX error: drmGetMagic failed\n");
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
version = drmGetVersion(fd);
|
|
|
|
if (version) {
|
2012-06-10 07:21:05 -06:00
|
|
|
drm_version.major = version->version_major;
|
|
|
|
drm_version.minor = version->version_minor;
|
|
|
|
drm_version.patch = version->version_patchlevel;
|
|
|
|
drmFreeVersion(version);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else {
|
2012-06-10 07:21:05 -06:00
|
|
|
drm_version.major = -1;
|
|
|
|
drm_version.minor = -1;
|
|
|
|
drm_version.patch = -1;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2007-03-03 04:09:19 -07:00
|
|
|
if (newlyopened && !DRIAuthConnection(pScreen, magic)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_ERROR, "AIGLX error: DRIAuthConnection failed\n");
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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,
|
2012-06-10 07:21:05 -06:00
|
|
|
&ddx_version.major,
|
|
|
|
&ddx_version.minor,
|
|
|
|
&ddx_version.patch, &driverName)) {
|
|
|
|
LogMessage(X_ERROR, "AIGLX error: DRIGetClientDriverName failed\n");
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -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,
|
|
|
|
__DRI_CORE, __DRI_CORE_VERSION,
|
|
|
|
(void **) &screen->legacy,
|
|
|
|
__DRI_LEGACY, __DRI_LEGACY_VERSION);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (screen->driver == NULL) {
|
|
|
|
goto handle_error;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* 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,
|
2012-06-10 07:21:05 -06:00
|
|
|
&framebuffer.size, &framebuffer.stride,
|
|
|
|
&framebuffer.dev_priv_size, &framebuffer.dev_priv)) {
|
|
|
|
LogMessage(X_ERROR, "AIGLX error: XF86DRIGetDeviceInfo failed\n");
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
framebuffer.width = pScreen->width;
|
|
|
|
framebuffer.height = pScreen->height;
|
|
|
|
|
|
|
|
/* Map the framebuffer region. */
|
2012-06-10 07:21:05 -06:00
|
|
|
status = drmMap(fd, hFB, framebuffer.size,
|
2013-06-07 11:28:45 -06:00
|
|
|
(drmAddressPtr) &framebuffer.base);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (status != 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_ERROR, "AIGLX error: drmMap of framebuffer failed (%s)\n",
|
|
|
|
strerror(-status));
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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) {
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_ERROR, "AIGLX error: drmMap of SAREA failed (%s)\n",
|
|
|
|
strerror(-status));
|
|
|
|
goto handle_error;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
screen->driScreen =
|
2012-06-10 07:21:05 -06:00
|
|
|
(*screen->legacy->createNewScreen) (pScreen->myNum,
|
|
|
|
&ddx_version,
|
|
|
|
&dri_version,
|
|
|
|
&drm_version,
|
|
|
|
&framebuffer,
|
|
|
|
pSAREA,
|
|
|
|
fd,
|
|
|
|
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;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
screen->base.fbconfigs = glxConvertConfigs(screen->core,
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->driConfigs,
|
|
|
|
GLX_WINDOW_BIT);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
initializeExtensions(screen);
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
DRIGetTexOffsetFuncs(pScreen, &screen->texOffsetStart,
|
2012-06-10 07:21:05 -06:00
|
|
|
&screen->texOffsetFinish);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
__glXScreenInit(&screen->base, pScreen);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* The first call simply determines the length of the extension string.
|
|
|
|
* This allows us to allocate some memory to hold the extension string,
|
|
|
|
* but it requires that we call __glXGetExtensionString a second time.
|
|
|
|
*/
|
2006-11-26 11:13:41 -07:00
|
|
|
buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
|
|
|
|
if (buffer_size > 0) {
|
2012-06-10 07:21:05 -06:00
|
|
|
free(screen->base.GLXextensions);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
screen->base.GLXextensions = xnfalloc(buffer_size);
|
|
|
|
(void) __glXGetExtensionString(screen->glx_enable_bits,
|
|
|
|
screen->base.GLXextensions);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
__glXsetEnterLeaveServerFuncs(__glXDRIenterServer, __glXDRIleaveServer);
|
|
|
|
|
|
|
|
screen->enterVT = pScrn->EnterVT;
|
2010-07-27 13:02:24 -06:00
|
|
|
pScrn->EnterVT = glxDRIEnterVT;
|
2006-11-26 11:13:41 -07:00
|
|
|
screen->leaveVT = pScrn->LeaveVT;
|
|
|
|
pScrn->LeaveVT = glxDRILeaveVT;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
LogMessage(X_INFO, "AIGLX: Loaded and initialized %s\n", driverName);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return &screen->base;
|
|
|
|
|
|
|
|
handle_error:
|
|
|
|
if (pSAREA != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
drmUnmap(pSAREA, SAREA_MAX);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (framebuffer.base != NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
drmUnmap((drmAddress) framebuffer.base, framebuffer.size);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (fd >= 0)
|
2012-06-10 07:21:05 -06:00
|
|
|
drmCloseOnce(fd);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
DRICloseConnection(pScreen);
|
|
|
|
|
|
|
|
if (screen->driver)
|
|
|
|
dlclose(screen->driver);
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
free(screen);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
LogMessage(X_ERROR, "AIGLX: reverting to software rendering\n");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
_X_EXPORT __GLXprovider __glXDRIProvider = {
|
2006-11-26 11:13:41 -07:00
|
|
|
__glXDRIscreenProbe,
|
|
|
|
"DRI",
|
|
|
|
NULL
|
|
|
|
};
|