Commit 5af77d43 authored by Kristian Høgsberg's avatar Kristian Høgsberg

DRI2: Drop sarea use, implement server side swap buffers.

parent 60ad8d5d
......@@ -356,7 +356,6 @@ AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes])
AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])
DRI=no
DRI2=no
KDRIVE_HW=no
dnl it would be nice to autodetect these *CONS_SUPPORTs
case $host_os in
......@@ -369,7 +368,6 @@ case $host_os in
AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
AC_DEFINE(SYSCONS_SUPPORT, 1, [System has syscons console])
DRI=yes
PKG_CHECK_EXISTS([dri2proto >= 1.1 libdrm >= 2.3.2], DRI2=yes, DRI2=no)
;;
*netbsd*)
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
......@@ -377,7 +375,6 @@ case $host_os in
AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
DRI=yes
PKG_CHECK_EXISTS([dri2proto >= 1.1 libdrm >= 2.3.2], DRI2=yes, DRI2=no)
;;
*openbsd*)
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
......@@ -386,7 +383,6 @@ case $host_os in
;;
*linux*)
DRI=yes
PKG_CHECK_EXISTS([dri2proto >= 1.1 libdrm >= 2.3.2], DRI2=yes, DRI2=no)
KDRIVE_HW=yes
;;
*solaris*)
......@@ -528,7 +524,7 @@ AC_ARG_ENABLE(xdmcp, AS_HELP_STRING([--disable-xdmcp], [Build XDMCP ext
AC_ARG_ENABLE(xdm-auth-1, AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
AC_ARG_ENABLE(dri, AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
AC_ARG_ENABLE(dri2, AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval])
AC_ARG_ENABLE(dri2, AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval], [DRI2=auto])
AC_ARG_ENABLE(xinerama, AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
AC_ARG_ENABLE(xf86vidmode, AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
AC_ARG_ENABLE(xace, AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
......@@ -856,13 +852,18 @@ if test "x$DRI" = xyes; then
AC_SUBST(GL_CFLAGS)
fi
#AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
#if test "x$DRI2" = xyes; then
# # FIXME: Bump the versions once we have releases of these.
# AC_DEFINE(DRI2, 1, [Build DRI2 extension])
# PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= 1.1])
# PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.3.2])
#fi
PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= 1.99.1],
[HAVE_DRI2PROTO=yes], [HAVE_DRI2PROTO=no])
case "$DRI2,$HAVE_DRI2PROTO" in
yes,no)
AC_MSG_ERROR([DRI2 requested, but dri2proto not found.])
;;
yes,yes | auto,yes)
AC_DEFINE(DRI2, 1, [Build DRI2 extension])
DRI2=yes
;;
esac
AM_CONDITIONAL(DRI2, test "x$DRI2" == xyes)
AM_CONDITIONAL(XINERAMA, [test "x$XINERAMA" = xyes])
if test "x$XINERAMA" = xyes; then
......
......@@ -435,6 +435,7 @@ static void StopUsingContext(__GLXcontext *glxc)
static void StartUsingContext(__GLXclientState *cl, __GLXcontext *glxc)
{
glxc->isCurrent = GL_TRUE;
__glXLastContext = glxc;
}
/**
......
......@@ -69,6 +69,7 @@ struct __GLXDRIscreen {
xf86LeaveVTProc *leaveVT;
const __DRIcoreExtension *core;
const __DRIdri2Extension *dri2;
const __DRIcopySubBufferExtension *copySubBuffer;
const __DRIswapControlExtension *swapControl;
const __DRItexBufferExtension *texBuffer;
......@@ -85,6 +86,12 @@ struct __GLXDRIdrawable {
__GLXdrawable base;
__DRIdrawable *driDrawable;
__GLXDRIscreen *screen;
/* Dimensions as last reported by DRI2GetBuffers. */
int width;
int height;
__DRIbuffer buffers[5];
int count;
};
static void
......@@ -107,9 +114,9 @@ static GLboolean
__glXDRIdrawableSwapBuffers(__GLXdrawable *drawable)
{
__GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
const __DRIcoreExtension *core = private->screen->core;
(*core->swapBuffers)(private->driDrawable);
DRI2SwapBuffers(drawable->pDraw,
0, 0, private->width, private->height);
return TRUE;
}
......@@ -118,26 +125,15 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *drawable)
static int
__glXDRIdrawableSwapInterval(__GLXdrawable *drawable, int interval)
{
__GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
const __DRIswapControlExtension *swapControl = private->screen->swapControl;
if (swapControl)
swapControl->setSwapInterval(private->driDrawable, interval);
return 0;
}
static void
__glXDRIdrawableCopySubBuffer(__GLXdrawable *basePrivate,
__glXDRIdrawableCopySubBuffer(__GLXdrawable *drawable,
int x, int y, int w, int h)
{
__GLXDRIdrawable *private = (__GLXDRIdrawable *) basePrivate;
const __DRIcopySubBufferExtension *copySubBuffer =
private->screen->copySubBuffer;
if (copySubBuffer)
(*copySubBuffer->copySubBuffer)(private->driDrawable, x, y, w, h);
DRI2SwapBuffers(drawable->pDraw, x, y, w, h);
}
static void
......@@ -275,7 +271,6 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
__GLXDRIscreen *screen = (__GLXDRIscreen *) baseScreen;
__GLXDRIcontext *context, *shareContext;
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
const __DRIcoreExtension *core = screen->core;
__DRIcontext *driShare;
shareContext = (__GLXDRIcontext *) baseShareContext;
......@@ -297,8 +292,9 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen,
context->base.textureFromPixmap = &__glXDRItextureFromPixmap;
context->driContext =
(*core->createNewContext)(screen->driScreen,
config->driConfig, driShare, context);
(*screen->dri2->createNewContext)(screen->driScreen,
config->driConfig,
driShare, context);
return &context->base;
}
......@@ -313,8 +309,6 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
__GLXDRIscreen *driScreen = (__GLXDRIscreen *) screen;
__GLXDRIconfig *config = (__GLXDRIconfig *) glxConfig;
__GLXDRIdrawable *private;
GLboolean retval;
unsigned int handle, head;
private = xalloc(sizeof *private);
if (private == NULL)
......@@ -333,42 +327,54 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
private->base.swapBuffers = __glXDRIdrawableSwapBuffers;
private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer;
retval = DRI2CreateDrawable(pDraw, &handle, &head);
if (DRI2CreateDrawable(pDraw)) {
xfree(private);
return NULL;
}
private->driDrawable =
(*driScreen->core->createNewDrawable)(driScreen->driScreen,
config->driConfig,
handle, head, private);
(*driScreen->dri2->createNewDrawable)(driScreen->driScreen,
config->driConfig, private);
return &private->base;
}
static void dri2ReemitDrawableInfo(__DRIdrawable *draw, unsigned int *tail,
void *loaderPrivate)
static __DRIbuffer *
dri2GetBuffers(__DRIdrawable *driDrawable,
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate)
{
__GLXDRIdrawable *pdraw = loaderPrivate;
__GLXDRIdrawable *private = loaderPrivate;
DRI2BufferPtr buffers;
int i;
DRI2ReemitDrawableInfo(pdraw->base.pDraw, tail);
}
buffers = DRI2GetBuffers(private->base.pDraw,
width, height, attachments, count, out_count);
if (*out_count > 5) {
*out_count = 0;
return NULL;
}
private->width = *width;
private->height = *height;
/* This assumes the DRI2 buffer attachment tokens matches the
* __DRIbuffer tokens. */
for (i = 0; i < *out_count; i++) {
private->buffers[i].attachment = buffers[i].attachment;
private->buffers[i].name = buffers[i].name;
private->buffers[i].pitch = buffers[i].pitch;
private->buffers[i].cpp = buffers[i].cpp;
private->buffers[i].flags = buffers[i].flags;
}
static void dri2PostDamage(__DRIdrawable *draw,
struct drm_clip_rect *rects,
int numRects, void *loaderPrivate)
{
__GLXDRIdrawable *drawable = loaderPrivate;
DrawablePtr pDraw = drawable->base.pDraw;
RegionRec region;
REGION_INIT(pDraw->pScreen, &region, (BoxPtr) rects, numRects);
REGION_TRANSLATE(pScreen, &region, pDraw->x, pDraw->y);
DamageDamageRegion(pDraw, &region);
REGION_UNINIT(pDraw->pScreen, &region);
return private->buffers;
}
static const __DRIloaderExtension loaderExtension = {
{ __DRI_LOADER, __DRI_LOADER_VERSION },
dri2ReemitDrawableInfo,
dri2PostDamage
static const __DRIdri2LoaderExtension loaderExtension = {
{ __DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION },
dri2GetBuffers,
};
static const __DRIextension *loader_extensions[] = {
......@@ -416,18 +422,11 @@ initializeExtensions(__GLXDRIscreen *screen)
extensions = screen->core->getExtensions(screen->driScreen);
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_COPY_SUB_BUFFER
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
screen->copySubBuffer =
(const __DRIcopySubBufferExtension *) extensions[i];
__glXEnableExtension(screen->glx_enable_bits,
"GLX_MESA_copy_sub_buffer");
LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
}
#endif
__glXEnableExtension(screen->glx_enable_bits,
"GLX_MESA_copy_sub_buffer");
LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_SWAP_CONTROL
if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
screen->swapControl =
......@@ -461,7 +460,6 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
char filename[128];
size_t buffer_size;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
unsigned int sareaHandle;
const __DRIextension **extensions;
const __DRIconfig **driConfigs;
int i;
......@@ -472,7 +470,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
memset(screen, 0, sizeof *screen);
if (!xf86LoaderCheckSymbol("DRI2Connect") ||
!DRI2Connect(pScreen, &screen->fd, &driverName, &sareaHandle)) {
!DRI2Connect(pScreen, &screen->fd, &driverName)) {
LogMessage(X_INFO,
"AIGLX: Screen %d is not DRI2 capable\n", pScreen->myNum);
return NULL;
......@@ -508,24 +506,28 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
extensions[i]->version >= __DRI_CORE_VERSION) {
screen->core = (const __DRIcoreExtension *) extensions[i];
}
if (strcmp(extensions[i]->name, __DRI_DRI2) == 0 &&
extensions[i]->version >= __DRI_DRI2_VERSION) {
screen->dri2 = (const __DRIdri2Extension *) extensions[i];
}
}
if (screen->core == NULL) {
if (screen->core == NULL || screen->dri2 == NULL) {
LogMessage(X_ERROR, "AIGLX error: %s exports no DRI extension\n",
driverName);
goto handle_error;
}
screen->driScreen =
(*screen->core->createNewScreen)(pScreen->myNum,
(*screen->dri2->createNewScreen)(pScreen->myNum,
screen->fd,
sareaHandle,
loader_extensions,
&driConfigs,
screen);
if (screen->driScreen == NULL) {
LogMessage(X_ERROR, "AIGLX error: Calling driver entry point failed");
LogMessage(X_ERROR,
"AIGLX error: Calling driver entry point failed\n");
goto handle_error;
}
......
This diff is collapsed.
......@@ -33,49 +33,67 @@
#ifndef _DRI2_H_
#define _DRI2_H_
typedef unsigned int (*DRI2GetPixmapHandleProcPtr)(PixmapPtr p,
unsigned int *flags);
typedef void (*DRI2BeginClipNotifyProcPtr)(ScreenPtr pScreen);
typedef void (*DRI2EndClipNotifyProcPtr)(ScreenPtr pScreen);
#include <X11/extensions/dri2tokens.h>
typedef struct {
unsigned int attachment;
unsigned int name;
unsigned int pitch;
unsigned int cpp;
unsigned int flags;
void *driverPrivate;
} DRI2BufferRec, *DRI2BufferPtr;
typedef DRI2BufferPtr (*DRI2CreateBuffersProcPtr)(DrawablePtr pDraw,
unsigned int *attachments,
int count);
typedef void (*DRI2DestroyBuffersProcPtr)(DrawablePtr pDraw,
DRI2BufferPtr buffers,
int count);
typedef void (*DRI2SwapBuffersProcPtr)(DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer,
int x,
int y,
int width,
int height);
typedef struct {
unsigned int version; /* Version of this struct */
int fd;
size_t driverSareaSize;
const char *driverName;
DRI2GetPixmapHandleProcPtr getPixmapHandle;
DRI2BeginClipNotifyProcPtr beginClipNotify;
DRI2EndClipNotifyProcPtr endClipNotify;
DRI2CreateBuffersProcPtr CreateBuffers;
DRI2DestroyBuffersProcPtr DestroyBuffers;
DRI2SwapBuffersProcPtr SwapBuffers;
} DRI2InfoRec, *DRI2InfoPtr;
void *DRI2ScreenInit(ScreenPtr pScreen,
DRI2InfoPtr info);
Bool DRI2ScreenInit(ScreenPtr pScreen,
DRI2InfoPtr info);
void DRI2CloseScreen(ScreenPtr pScreen);
Bool DRI2Connect(ScreenPtr pScreen,
int *fd,
const char **driverName,
unsigned int *sareaHandle);
const char **driverName);
Bool DRI2AuthConnection(ScreenPtr pScreen, drm_magic_t magic);
unsigned int DRI2GetPixmapHandle(PixmapPtr pPixmap,
unsigned int *flags);
void DRI2Lock(ScreenPtr pScreen);
void DRI2Unlock(ScreenPtr pScreen);
Bool DRI2CreateDrawable(DrawablePtr pDraw,
unsigned int *handle,
unsigned int *head);
int DRI2CreateDrawable(DrawablePtr pDraw);
void DRI2DestroyDrawable(DrawablePtr pDraw);
void DRI2ReemitDrawableInfo(DrawablePtr pDraw,
unsigned int *head);
DRI2BufferPtr DRI2GetBuffers(DrawablePtr pDraw,
int *width,
int *height,
unsigned int *attachments,
int count,
int *out_count);
Bool DRI2PostDamage(DrawablePtr pDrawable,
struct drm_clip_rect *rects, int numRects);
void DRI2SwapBuffers(DrawablePtr pDraw,
int x,
int y,
int width,
int height);
#endif
......@@ -115,7 +115,6 @@ ProcDRI2Connect(ClientPtr client)
int fd;
const char *driverName;
char *busId = NULL;
unsigned int sareaHandle;
REQUEST_SIZE_MATCH(xDRI2ConnectReq);
if (!validScreen(client, stuff->screen, &pScreen))
......@@ -126,9 +125,8 @@ ProcDRI2Connect(ClientPtr client)
rep.sequenceNumber = client->sequence;
rep.driverNameLength = 0;
rep.busIdLength = 0;
rep.sareaHandle = 0;
if (!DRI2Connect(pScreen, &fd, &driverName, &sareaHandle))
if (!DRI2Connect(pScreen, &fd, &driverName))
goto fail;
busId = drmGetBusid(fd);
......@@ -137,7 +135,6 @@ ProcDRI2Connect(ClientPtr client)
rep.driverNameLength = strlen(driverName);
rep.busIdLength = strlen(busId);
rep.sareaHandle = sareaHandle;
rep.length = (rep.driverNameLength + 3) / 4 + (rep.busIdLength + 3) / 4;
fail:
......@@ -180,9 +177,7 @@ static int
ProcDRI2CreateDrawable(ClientPtr client)
{
REQUEST(xDRI2CreateDrawableReq);
xDRI2CreateDrawableReply rep;
DrawablePtr pDrawable;
unsigned int handle, head;
int status;
REQUEST_SIZE_MATCH(xDRI2CreateDrawableReq);
......@@ -190,22 +185,15 @@ ProcDRI2CreateDrawable(ClientPtr client)
if (!validDrawable(client, stuff->drawable, &pDrawable, &status))
return status;
if (!DRI2CreateDrawable(pDrawable, &handle, &head))
return BadMatch;
status = DRI2CreateDrawable(pDrawable);
if (status != Success)
return status;
if (!AddResource(stuff->drawable, dri2DrawableRes, pDrawable)) {
DRI2DestroyDrawable(pDrawable);
return BadAlloc;
}
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.handle = handle;
rep.head = head;
WriteToClient(client, sizeof(xDRI2CreateDrawableReply), &rep);
return client->noClientException;
}
......@@ -226,26 +214,69 @@ ProcDRI2DestroyDrawable(ClientPtr client)
}
static int
ProcDRI2ReemitDrawableInfo(ClientPtr client)
ProcDRI2GetBuffers(ClientPtr client)
{
REQUEST(xDRI2ReemitDrawableInfoReq);
xDRI2ReemitDrawableInfoReply rep;
REQUEST(xDRI2GetBuffersReq);
xDRI2GetBuffersReply rep;
DrawablePtr pDrawable;
DRI2BufferPtr buffers;
int i, status, width, height, count;
unsigned int *attachments;
xDRI2Buffer buffer;
REQUEST_FIXED_SIZE(xDRI2GetBuffersReq, stuff->count * 4);
if (!validDrawable(client, stuff->drawable, &pDrawable, &status))
return status;
attachments = (CARD32 *) &stuff[1];
buffers = DRI2GetBuffers(pDrawable, &width, &height,
attachments, stuff->count, &count);
rep.type = X_Reply;
rep.length = count * sizeof(xDRI2Buffer) / 4;
rep.sequenceNumber = client->sequence;
rep.width = width;
rep.height = height;
rep.count = count;
WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep);
for (i = 0; i < count; i++) {
buffer.attachment = buffers[i].attachment;
buffer.name = buffers[i].name;
buffer.pitch = buffers[i].pitch;
buffer.cpp = buffers[i].cpp;
buffer.flags = buffers[i].flags;
WriteToClient(client, sizeof(xDRI2Buffer), &buffer);
}
return client->noClientException;
}
static int
ProcDRI2SwapBuffers(ClientPtr client)
{
REQUEST(xDRI2SwapBuffersReq);
xDRI2SwapBuffersReply rep;
DrawablePtr pDrawable;
unsigned int head;
int status;
REQUEST_SIZE_MATCH(xDRI2ReemitDrawableInfoReq);
REQUEST_SIZE_MATCH(xDRI2SwapBuffersReq);
if (!validDrawable(client, stuff->drawable, &pDrawable, &status))
return status;
DRI2ReemitDrawableInfo(pDrawable, &head);
/* Swap buffers need to do a round trip to make sure the X server
* queues the swap buffer rendering commands before the DRI client
* continues rendering.
*/
DRI2SwapBuffers(pDrawable, stuff->x, stuff->y,
stuff->width, stuff->height);
rep.type = X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.head = head;
WriteToClient(client, sizeof(xDRI2ReemitDrawableInfoReply), &rep);
WriteToClient(client, sizeof(xDRI2SwapBuffersReply), &rep);
return client->noClientException;
}
......@@ -272,8 +303,10 @@ ProcDRI2Dispatch (ClientPtr client)
return ProcDRI2CreateDrawable(client);
case X_DRI2DestroyDrawable:
return ProcDRI2DestroyDrawable(client);
case X_DRI2ReemitDrawableInfo:
return ProcDRI2ReemitDrawableInfo(client);
case X_DRI2GetBuffers:
return ProcDRI2GetBuffers(client);
case X_DRI2SwapBuffers:
return ProcDRI2SwapBuffers(client);
default:
return BadRequest;
}
......@@ -297,7 +330,6 @@ SProcDRI2Connect(ClientPtr client)
rep.length = 0;
rep.driverNameLength = 0;
rep.busIdLength = 0;
rep.sareaHandle = 0;
return client->noClientException;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment