2008-02-04 17:58:24 +01:00
|
|
|
/*
|
2008-08-11 22:59:17 +02:00
|
|
|
* Copyright © 2007, 2008 Red Hat, Inc.
|
2008-02-04 17:58:24 +01:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Soft-
|
|
|
|
* ware"), to deal in the Software without restriction, including without
|
|
|
|
* limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, provided that the above copyright
|
|
|
|
* notice(s) and this permission notice appear in all copies of the Soft-
|
|
|
|
* ware and that both the above copyright notice(s) and this permission
|
|
|
|
* notice appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
|
|
|
|
* ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
|
|
|
|
* RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
|
|
|
|
* THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
|
|
|
|
* QUENTIAL 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 PERFOR-
|
|
|
|
* MANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name of a copyright holder shall
|
|
|
|
* not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
* other dealings in this Software without prior written authorization of
|
|
|
|
* the copyright holder.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Kristian Høgsberg (krh@redhat.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
#include <errno.h>
|
2010-01-22 17:34:36 +01:00
|
|
|
#ifdef WITH_LIBDRM
|
2008-02-04 17:58:24 +01:00
|
|
|
#include <xf86drm.h>
|
2010-01-22 17:34:36 +01:00
|
|
|
#endif
|
2008-02-04 17:58:24 +01:00
|
|
|
#include "xf86Module.h"
|
2010-04-29 22:36:10 +02:00
|
|
|
#include "list.h"
|
2008-02-04 17:58:24 +01:00
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "windowstr.h"
|
2009-07-16 15:01:17 +02:00
|
|
|
#include "dixstruct.h"
|
2008-02-04 17:58:24 +01:00
|
|
|
#include "dri2.h"
|
2012-07-10 03:03:18 +02:00
|
|
|
#include "dri2int.h"
|
2009-08-28 03:39:42 +02:00
|
|
|
#include "xf86VGAarbiter.h"
|
2012-06-26 11:20:52 +02:00
|
|
|
#include "damage.h"
|
2008-02-04 17:58:24 +01:00
|
|
|
#include "xf86.h"
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD8 dri2_major; /* version of DRI2 supported by DDX */
|
2010-03-08 21:38:37 +01:00
|
|
|
CARD8 dri2_minor;
|
|
|
|
|
2012-07-07 11:10:08 +02:00
|
|
|
uint32_t prime_id_allocate_bitmask;
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
#define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
|
|
|
|
|
|
|
|
static DevPrivateKeyRec dri2WindowPrivateKeyRec;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
#define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
|
|
|
|
|
|
|
|
static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
static DevPrivateKeyRec dri2ClientPrivateKeyRec;
|
|
|
|
|
|
|
|
#define dri2ClientPrivateKey (&dri2ClientPrivateKeyRec)
|
|
|
|
|
|
|
|
#define dri2ClientPrivate(_pClient) (dixLookupPrivate(&(_pClient)->devPrivates, \
|
|
|
|
dri2ClientPrivateKey))
|
|
|
|
|
|
|
|
typedef struct _DRI2Client {
|
|
|
|
int prime_id;
|
|
|
|
} DRI2ClientRec, *DRI2ClientPtr;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static RESTYPE dri2DrawableRes;
|
2010-04-16 11:55:34 +02:00
|
|
|
|
|
|
|
typedef struct _DRI2Screen *DRI2ScreenPtr;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
typedef struct _DRI2Drawable {
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2ScreenPtr dri2_screen;
|
|
|
|
DrawablePtr drawable;
|
|
|
|
struct xorg_list reference_list;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
DRI2BufferPtr *buffers;
|
|
|
|
int bufferCount;
|
|
|
|
unsigned int swapsPending;
|
|
|
|
ClientPtr blockedClient;
|
|
|
|
Bool blockedOnMsc;
|
|
|
|
int swap_interval;
|
|
|
|
CARD64 swap_count;
|
|
|
|
int64_t target_sbc; /* -1 means no SBC wait outstanding */
|
|
|
|
CARD64 last_swap_target; /* most recently queued swap target */
|
|
|
|
CARD64 last_swap_msc; /* msc at completion of most recent swap */
|
|
|
|
CARD64 last_swap_ust; /* ust at completion of most recent swap */
|
|
|
|
int swap_limit; /* for N-buffering */
|
|
|
|
Bool needInvalidate;
|
2012-06-26 11:20:52 +02:00
|
|
|
int prime_id;
|
|
|
|
PixmapPtr prime_slave_pixmap;
|
|
|
|
PixmapPtr redirectpixmap;
|
2008-08-11 22:59:17 +02:00
|
|
|
} DRI2DrawableRec, *DRI2DrawablePtr;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
|
|
|
typedef struct _DRI2Screen {
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenPtr screen;
|
|
|
|
int refcnt;
|
|
|
|
unsigned int numDrivers;
|
|
|
|
const char **driverNames;
|
|
|
|
const char *deviceName;
|
|
|
|
int fd;
|
|
|
|
unsigned int lastSequence;
|
2012-07-07 11:10:08 +02:00
|
|
|
int prime_id;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
DRI2CreateBufferProcPtr CreateBuffer;
|
|
|
|
DRI2DestroyBufferProcPtr DestroyBuffer;
|
|
|
|
DRI2CopyRegionProcPtr CopyRegion;
|
|
|
|
DRI2ScheduleSwapProcPtr ScheduleSwap;
|
|
|
|
DRI2GetMSCProcPtr GetMSC;
|
|
|
|
DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
|
2012-06-20 05:53:53 +02:00
|
|
|
DRI2AuthMagic2ProcPtr AuthMagic;
|
|
|
|
DRI2AuthMagicProcPtr LegacyAuthMagic;
|
2010-11-01 15:21:59 +01:00
|
|
|
DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
|
2010-11-01 15:02:11 +01:00
|
|
|
DRI2SwapLimitValidateProcPtr SwapLimitValidate;
|
2012-05-03 01:18:49 +02:00
|
|
|
DRI2GetParamProcPtr GetParam;
|
2008-10-07 19:49:28 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
HandleExposuresProcPtr HandleExposures;
|
2010-05-11 16:52:18 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ConfigNotifyProcPtr ConfigNotify;
|
2012-06-26 11:20:52 +02:00
|
|
|
DRI2CreateBuffer2ProcPtr CreateBuffer2;
|
|
|
|
DRI2DestroyBuffer2ProcPtr DestroyBuffer2;
|
|
|
|
DRI2CopyRegion2ProcPtr CopyRegion2;
|
2009-07-16 15:01:17 +02:00
|
|
|
} DRI2ScreenRec;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
static void
|
|
|
|
destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, int prime_id);
|
|
|
|
|
2008-02-04 17:58:24 +01:00
|
|
|
static DRI2ScreenPtr
|
|
|
|
DRI2GetScreen(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
|
|
|
|
}
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
static ScreenPtr
|
|
|
|
GetScreenPrime(ScreenPtr master, int prime_id)
|
|
|
|
{
|
|
|
|
ScreenPtr slave;
|
|
|
|
if (prime_id == 0 || xorg_list_is_empty(&master->offload_slave_list)) {
|
|
|
|
return master;
|
|
|
|
}
|
|
|
|
xorg_list_for_each_entry(slave, &master->offload_slave_list, offload_head) {
|
2012-07-07 11:10:08 +02:00
|
|
|
DRI2ScreenPtr ds;
|
|
|
|
|
|
|
|
ds = DRI2GetScreen(slave);
|
|
|
|
if (ds->prime_id == prime_id)
|
2014-04-15 17:54:35 +02:00
|
|
|
return slave;
|
2012-06-26 11:20:52 +02:00
|
|
|
}
|
2014-04-15 17:54:35 +02:00
|
|
|
return master;
|
2012-06-26 11:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static DRI2ScreenPtr
|
|
|
|
DRI2GetScreenPrime(ScreenPtr master, int prime_id)
|
|
|
|
{
|
|
|
|
ScreenPtr slave = GetScreenPrime(master, prime_id);
|
|
|
|
return DRI2GetScreen(slave);
|
|
|
|
}
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
static DRI2DrawablePtr
|
|
|
|
DRI2GetDrawable(DrawablePtr pDraw)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2010-04-29 22:36:10 +02:00
|
|
|
WindowPtr pWin;
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
2010-06-10 16:15:49 +02:00
|
|
|
switch (pDraw->type) {
|
|
|
|
case DRAWABLE_WINDOW:
|
2012-03-21 20:55:09 +01:00
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
|
2010-06-10 16:15:49 +02:00
|
|
|
case DRAWABLE_PIXMAP:
|
2012-03-21 20:55:09 +01:00
|
|
|
pPixmap = (PixmapPtr) pDraw;
|
|
|
|
return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
|
2010-06-10 16:15:49 +02:00
|
|
|
default:
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2010-04-29 22:36:10 +02:00
|
|
|
}
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2010-04-29 22:36:10 +02:00
|
|
|
static DRI2DrawablePtr
|
|
|
|
DRI2AllocateDrawable(DrawablePtr pDraw)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
2008-08-11 22:59:17 +02:00
|
|
|
DRI2DrawablePtr pPriv;
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD64 ust;
|
2010-04-29 22:36:10 +02:00
|
|
|
WindowPtr pWin;
|
|
|
|
PixmapPtr pPixmap;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
pPriv = malloc(sizeof *pPriv);
|
2008-08-11 22:59:17 +02:00
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2010-04-16 11:55:34 +02:00
|
|
|
pPriv->dri2_screen = ds;
|
2010-04-29 22:36:10 +02:00
|
|
|
pPriv->drawable = pDraw;
|
2008-08-11 22:59:17 +02:00
|
|
|
pPriv->width = pDraw->width;
|
|
|
|
pPriv->height = pDraw->height;
|
|
|
|
pPriv->buffers = NULL;
|
|
|
|
pPriv->bufferCount = 0;
|
2009-07-16 15:01:17 +02:00
|
|
|
pPriv->swapsPending = 0;
|
|
|
|
pPriv->blockedClient = NULL;
|
2010-03-09 00:10:47 +01:00
|
|
|
pPriv->blockedOnMsc = FALSE;
|
2009-07-16 15:01:17 +02:00
|
|
|
pPriv->swap_count = 0;
|
|
|
|
pPriv->target_sbc = -1;
|
|
|
|
pPriv->swap_interval = 1;
|
2010-03-04 18:19:13 +01:00
|
|
|
/* Initialize last swap target from DDX if possible */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!ds->GetMSC || !(*ds->GetMSC) (pDraw, &ust, &pPriv->last_swap_target))
|
|
|
|
pPriv->last_swap_target = 0;
|
2010-03-04 18:19:13 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pPriv->swap_limit = 1; /* default to double buffering */
|
DRI2WaitSbc(): Fixes for correct semantic of glXWaitForSbcOML()
Added implementation for case target_sbc == 0. In that case, the
function shall schedule a wait until all pending swaps for the drawable
have completed.
Fix for non-blocking case. Old implementation returned random,
uninitialized values for (ust,msc,sbc) if it returned immediately
without scheduling a wait due to sbc >= target_sbc.
Now if function doesn't schedule a wait, but returns immediately,
it returns the (ust,msc,sbc) of the most recently completed swap,
i.e., the UST and MSC corresponding to the time when the returned
current SBC was reached.
Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
2010-02-21 05:26:00 +01:00
|
|
|
pPriv->last_swap_msc = 0;
|
|
|
|
pPriv->last_swap_ust = 0;
|
2012-01-27 01:41:25 +01:00
|
|
|
xorg_list_init(&pPriv->reference_list);
|
2011-12-18 17:29:38 +01:00
|
|
|
pPriv->needInvalidate = FALSE;
|
2012-06-26 11:20:52 +02:00
|
|
|
pPriv->redirectpixmap = NULL;
|
|
|
|
pPriv->prime_slave_pixmap = NULL;
|
2010-06-10 16:15:49 +02:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
2012-03-21 20:55:09 +01:00
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pPixmap = (PixmapPtr) pDraw;
|
|
|
|
dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
|
2010-04-29 22:36:10 +02:00
|
|
|
}
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2010-04-29 22:36:10 +02:00
|
|
|
return pPriv;
|
|
|
|
}
|
|
|
|
|
2010-11-01 15:22:00 +01:00
|
|
|
Bool
|
|
|
|
DRI2SwapLimit(DrawablePtr pDraw, int swap_limit)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
|
2010-11-01 15:02:11 +01:00
|
|
|
DRI2ScreenPtr ds;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-11-01 15:22:00 +01:00
|
|
|
if (!pPriv)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2010-11-01 15:22:00 +01:00
|
|
|
|
2010-11-01 15:02:11 +01:00
|
|
|
ds = pPriv->dri2_screen;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!ds->SwapLimitValidate || !ds->SwapLimitValidate(pDraw, swap_limit))
|
|
|
|
return FALSE;
|
2010-11-01 15:02:11 +01:00
|
|
|
|
2010-11-01 15:22:00 +01:00
|
|
|
pPriv->swap_limit = swap_limit;
|
|
|
|
|
|
|
|
/* Check throttling */
|
|
|
|
if (pPriv->swapsPending >= pPriv->swap_limit)
|
2012-03-21 20:55:09 +01:00
|
|
|
return TRUE;
|
2010-11-01 15:22:00 +01:00
|
|
|
|
|
|
|
if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pPriv->blockedClient) {
|
|
|
|
AttendClient(pPriv->blockedClient);
|
|
|
|
pPriv->blockedClient = NULL;
|
|
|
|
}
|
2010-11-01 15:22:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-04-29 22:36:10 +02:00
|
|
|
typedef struct DRI2DrawableRefRec {
|
2012-03-21 20:55:09 +01:00
|
|
|
XID id;
|
|
|
|
XID dri2_id;
|
|
|
|
DRI2InvalidateProcPtr invalidate;
|
|
|
|
void *priv;
|
|
|
|
struct xorg_list link;
|
2010-04-29 22:36:10 +02:00
|
|
|
} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
|
|
|
|
|
|
|
|
static DRI2DrawableRefPtr
|
|
|
|
DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
|
|
|
|
{
|
|
|
|
DRI2DrawableRefPtr ref;
|
|
|
|
|
2012-01-27 01:41:25 +01:00
|
|
|
xorg_list_for_each_entry(ref, &pPriv->reference_list, link) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (ref->id == id)
|
|
|
|
return ref;
|
2010-04-29 22:36:10 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-04-29 22:36:10 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-05-11 16:52:18 +02:00
|
|
|
DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2InvalidateProcPtr invalidate, void *priv)
|
2010-04-29 22:36:10 +02:00
|
|
|
{
|
|
|
|
DRI2DrawableRefPtr ref;
|
|
|
|
|
|
|
|
ref = malloc(sizeof *ref);
|
|
|
|
if (ref == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
|
|
|
|
2011-03-25 17:56:02 +01:00
|
|
|
if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) {
|
2012-03-21 20:55:09 +01:00
|
|
|
free(ref);
|
|
|
|
return BadAlloc;
|
2011-03-25 17:56:02 +01:00
|
|
|
}
|
2010-04-29 22:36:10 +02:00
|
|
|
if (!DRI2LookupDrawableRef(pPriv, id))
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!AddResource(id, dri2DrawableRes, pPriv)) {
|
|
|
|
FreeResourceByType(dri2_id, dri2DrawableRes, TRUE);
|
|
|
|
free(ref);
|
|
|
|
return BadAlloc;
|
2011-03-25 17:56:02 +01:00
|
|
|
}
|
2010-04-29 22:36:10 +02:00
|
|
|
|
|
|
|
ref->id = id;
|
2012-03-21 20:55:09 +01:00
|
|
|
ref->dri2_id = dri2_id;
|
2010-05-11 16:52:18 +02:00
|
|
|
ref->invalidate = invalidate;
|
|
|
|
ref->priv = priv;
|
2012-01-27 01:41:25 +01:00
|
|
|
xorg_list_add(&ref->link, &pPriv->reference_list);
|
2010-04-29 22:36:10 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-07-12 13:16:36 +02:00
|
|
|
DRI2CreateDrawable2(ClientPtr client, DrawablePtr pDraw, XID id,
|
|
|
|
DRI2InvalidateProcPtr invalidate, void *priv,
|
|
|
|
XID *dri2_id_out)
|
2010-04-29 22:36:10 +02:00
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
2012-06-26 11:20:52 +02:00
|
|
|
DRI2ClientPtr dri2_client = dri2ClientPrivate(client);
|
2010-04-29 22:36:10 +02:00
|
|
|
XID dri2_id;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
pPriv = DRI2AllocateDrawable(pDraw);
|
2010-04-29 22:36:10 +02:00
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadAlloc;
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
pPriv->prime_id = dri2_client->prime_id;
|
|
|
|
|
2010-04-29 22:36:10 +02:00
|
|
|
dri2_id = FakeClientID(client->index);
|
2010-05-11 16:52:18 +02:00
|
|
|
rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv);
|
2010-04-29 22:36:10 +02:00
|
|
|
if (rc != Success)
|
2012-03-21 20:55:09 +01:00
|
|
|
return rc;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2012-07-12 13:16:36 +02:00
|
|
|
if (dri2_id_out)
|
|
|
|
*dri2_id_out = dri2_id;
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
return Success;
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2012-07-12 13:16:36 +02:00
|
|
|
int
|
|
|
|
DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
|
|
|
|
DRI2InvalidateProcPtr invalidate, void *priv)
|
|
|
|
{
|
|
|
|
return DRI2CreateDrawable2(client, pDraw, id, invalidate, priv, NULL);
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
static int
|
2013-12-15 10:05:51 +01:00
|
|
|
DRI2DrawableGone(void *p, XID id)
|
2010-01-25 18:21:51 +01:00
|
|
|
{
|
2010-04-16 11:55:34 +02:00
|
|
|
DRI2DrawablePtr pPriv = p;
|
2010-04-29 22:36:10 +02:00
|
|
|
DRI2DrawableRefPtr ref, next;
|
|
|
|
WindowPtr pWin;
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
DrawablePtr pDraw;
|
2010-04-16 11:55:34 +02:00
|
|
|
int i;
|
2010-01-25 18:21:51 +01:00
|
|
|
|
2012-01-27 01:41:25 +01:00
|
|
|
xorg_list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (ref->dri2_id == id) {
|
|
|
|
xorg_list_del(&ref->link);
|
|
|
|
/* If this was the last ref under this X drawable XID,
|
|
|
|
* unregister the X drawable resource. */
|
|
|
|
if (!DRI2LookupDrawableRef(pPriv, ref->id))
|
|
|
|
FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
|
|
|
|
free(ref);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ref->id == id) {
|
|
|
|
xorg_list_del(&ref->link);
|
|
|
|
FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
|
|
|
|
free(ref);
|
|
|
|
}
|
2010-04-29 22:36:10 +02:00
|
|
|
}
|
|
|
|
|
2012-01-27 01:41:25 +01:00
|
|
|
if (!xorg_list_is_empty(&pPriv->reference_list))
|
2012-03-21 20:55:09 +01:00
|
|
|
return Success;
|
2010-04-29 22:36:10 +02:00
|
|
|
|
|
|
|
pDraw = pPriv->drawable;
|
2010-06-10 16:15:49 +02:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
2012-03-21 20:55:09 +01:00
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pPixmap = (PixmapPtr) pDraw;
|
|
|
|
dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
|
2010-04-29 22:36:10 +02:00
|
|
|
}
|
|
|
|
|
2012-08-03 08:42:44 +02:00
|
|
|
if (pPriv->prime_slave_pixmap) {
|
|
|
|
(*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
|
|
|
|
(*pPriv->prime_slave_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap);
|
|
|
|
}
|
|
|
|
|
2010-04-16 11:55:34 +02:00
|
|
|
if (pPriv->buffers != NULL) {
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0; i < pPriv->bufferCount; i++)
|
2012-06-26 11:20:52 +02:00
|
|
|
destroy_buffer(pDraw, pPriv->buffers[i], pPriv->prime_id);
|
2010-04-16 11:55:34 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
free(pPriv->buffers);
|
2010-04-16 11:55:34 +02:00
|
|
|
}
|
2010-01-25 18:21:51 +01:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
if (pPriv->redirectpixmap) {
|
|
|
|
(*pDraw->pScreen->ReplaceScanoutPixmap)(pDraw, pPriv->redirectpixmap, FALSE);
|
|
|
|
(*pDraw->pScreen->DestroyPixmap)(pPriv->redirectpixmap);
|
|
|
|
}
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pPriv);
|
2010-01-25 18:21:51 +01:00
|
|
|
|
2010-04-16 11:55:34 +02:00
|
|
|
return Success;
|
2010-01-25 18:21:51 +01:00
|
|
|
}
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
static DRI2BufferPtr
|
|
|
|
create_buffer(DrawablePtr pDraw,
|
|
|
|
unsigned int attachment, unsigned int format)
|
|
|
|
{
|
|
|
|
ScreenPtr primeScreen;
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
DRI2ScreenPtr ds;
|
|
|
|
DRI2BufferPtr buffer;
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
primeScreen = GetScreenPrime(pDraw->pScreen, pPriv->prime_id);
|
|
|
|
ds = DRI2GetScreenPrime(pDraw->pScreen, pPriv->prime_id);
|
|
|
|
if (ds->CreateBuffer2)
|
|
|
|
buffer = (*ds->CreateBuffer2)(primeScreen, pDraw, attachment, format);
|
|
|
|
else
|
|
|
|
buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, int prime_id)
|
|
|
|
{
|
|
|
|
ScreenPtr primeScreen;
|
|
|
|
DRI2ScreenPtr ds;
|
|
|
|
primeScreen = GetScreenPrime(pDraw->pScreen, prime_id);
|
|
|
|
ds = DRI2GetScreen(primeScreen);
|
|
|
|
if (ds->DestroyBuffer2)
|
|
|
|
(*ds->DestroyBuffer2)(primeScreen, pDraw, buffer);
|
|
|
|
else
|
|
|
|
(*ds->DestroyBuffer)(pDraw, buffer);
|
|
|
|
}
|
|
|
|
|
2009-04-24 21:49:19 +02:00
|
|
|
static int
|
2009-07-01 23:01:57 +02:00
|
|
|
find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
|
2009-04-24 21:49:19 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2009-07-01 23:01:57 +02:00
|
|
|
if (pPriv->buffers == NULL) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return -1;
|
2009-04-24 21:49:19 +02:00
|
|
|
}
|
|
|
|
|
2009-07-01 23:01:57 +02:00
|
|
|
for (i = 0; i < pPriv->bufferCount; i++) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((pPriv->buffers[i] != NULL)
|
|
|
|
&& (pPriv->buffers[i]->attachment == attachment)) {
|
|
|
|
return i;
|
|
|
|
}
|
2009-04-24 21:49:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-02-24 23:18:01 +01:00
|
|
|
static Bool
|
2009-04-24 21:49:19 +02:00
|
|
|
allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2DrawablePtr pPriv,
|
|
|
|
unsigned int attachment, unsigned int format,
|
|
|
|
int dimensions_match, DRI2BufferPtr * buffer)
|
2009-04-24 21:49:19 +02:00
|
|
|
{
|
2010-02-24 23:18:01 +01:00
|
|
|
int old_buf = find_attachment(pPriv, attachment);
|
2009-04-24 21:49:19 +02:00
|
|
|
|
|
|
|
if ((old_buf < 0)
|
2012-03-21 20:55:09 +01:00
|
|
|
|| attachment == DRI2BufferFrontLeft
|
|
|
|
|| !dimensions_match || (pPriv->buffers[old_buf]->format != format)) {
|
2012-06-26 11:20:52 +02:00
|
|
|
*buffer = create_buffer (pDraw, attachment, format);
|
2012-03-21 20:55:09 +01:00
|
|
|
return TRUE;
|
2010-02-24 23:18:01 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
*buffer = pPriv->buffers[old_buf];
|
2010-11-01 15:21:59 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (ds->ReuseBufferNotify)
|
|
|
|
(*ds->ReuseBufferNotify) (pDraw, *buffer);
|
2010-11-01 15:21:59 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pPriv->buffers[old_buf] = NULL;
|
|
|
|
return FALSE;
|
2009-04-24 21:49:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-14 15:25:43 +02:00
|
|
|
static void
|
|
|
|
update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2BufferPtr * buffers, int out_count, int *width,
|
|
|
|
int *height)
|
2010-05-14 15:25:43 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (pPriv->buffers != NULL) {
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0; i < pPriv->bufferCount; i++) {
|
|
|
|
if (pPriv->buffers[i] != NULL) {
|
2012-06-26 11:20:52 +02:00
|
|
|
destroy_buffer(pDraw, pPriv->buffers[i], pPriv->prime_id);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
}
|
2010-05-14 15:25:43 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
free(pPriv->buffers);
|
2010-05-14 15:25:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pPriv->buffers = buffers;
|
2011-04-12 16:16:50 +02:00
|
|
|
pPriv->bufferCount = out_count;
|
2010-05-14 15:25:43 +02:00
|
|
|
pPriv->width = pDraw->width;
|
|
|
|
pPriv->height = pDraw->height;
|
|
|
|
*width = pPriv->width;
|
|
|
|
*height = pPriv->height;
|
|
|
|
}
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
static DRI2BufferPtr *
|
2009-04-24 21:49:19 +02:00
|
|
|
do_get_buffers(DrawablePtr pDraw, int *width, int *height,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned int *attachments, int count, int *out_count,
|
|
|
|
int has_format)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2008-08-11 22:59:17 +02:00
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
|
2012-06-26 11:20:52 +02:00
|
|
|
DRI2ScreenPtr ds;
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2BufferPtr *buffers;
|
2009-04-24 21:49:19 +02:00
|
|
|
int need_real_front = 0;
|
|
|
|
int need_fake_front = 0;
|
2009-04-09 23:38:24 +02:00
|
|
|
int have_fake_front = 0;
|
2009-04-24 21:49:19 +02:00
|
|
|
int front_format = 0;
|
2009-06-23 16:45:39 +02:00
|
|
|
int dimensions_match;
|
2010-02-24 23:18:01 +01:00
|
|
|
int buffers_changed = 0;
|
2009-04-24 21:49:19 +02:00
|
|
|
int i;
|
2009-04-09 00:44:34 +02:00
|
|
|
|
2009-06-23 16:45:39 +02:00
|
|
|
if (!pPriv) {
|
2012-03-21 20:55:09 +01:00
|
|
|
*width = pDraw->width;
|
|
|
|
*height = pDraw->height;
|
|
|
|
*out_count = 0;
|
|
|
|
return NULL;
|
2009-06-23 16:45:39 +02:00
|
|
|
}
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
|
2009-06-23 16:45:39 +02:00
|
|
|
dimensions_match = (pDraw->width == pPriv->width)
|
Revert "DRI2: re-allocate DRI2 drawable if pixmap serial changes"
This reverts commit 3209b094a3b1466b579e8020e12a4f3fa78a5f3f. After a
long debug session by Paul Berry, it appears that this was the commit
that has been producing sporadic failures in piglit front buffer
rendering tests for the last several years.
GetBuffers may return fresh buffers with invalid contents at a couple
reasonable times:
- When first asked for a non-fake-front buffer.
- When the drawable size is changed, an Invalidate has been sent, and
obviously the app needs to redraw the whole buffer.
- After a glXSwapBuffers(), GL allows the backbuffer to be undefined,
and an Invalidate was sent to tell the GL that it should grab these
appropriate new buffers to avoid stalling.
But with the patch being reverted, GetBuffers would also return fresh
invalid buffers when the drawable serial number changed, which is
approximately "whenever, for any reason". The app is not expecting
invalid buffer contents "whenever", nor is it valid. Because the GL
usually only GetBuffers after an Invalidate is sent, and the new
buffer allocation only happened during a GetBuffers, most apps saw no
problems. But apps that do (fake-)frontbuffer rendering do frequently
ask the server for the front buffer (since we drop the fake front
allocation when we're not doing front buffer rendering), and if the
drawable serial got bumped midway through a draw, the server would
pointlessly ditch the front *and* backbuffer full of important
drawing, resulting in bad rendering.
The patch was originally to fix bugzilla:
https://bugs.freedesktop.org/show_bug.cgi?id=28365
Specifically:
To reproduce, start with a large-ish display (i.e. 1680x1050 on my
laptop), use the patched glxgears from bug 28252 to add the
-override option. Then run glxgears -override -geometry 640x480
to create a 640x480 window in the top left corner, which will work
fine. Next, run xrandr -s 640x480 and watch the fireworks.
I've tested with an override-redirect glxgears, both with vblank sync
enabled and disabled, both with gnome-shell and no window manager at
all, before and after this patch. The only problem observed was that
before and after the revert, sometimes when alt-tabbing to kill my
gears after completing the test gnome-shell would get confused about
override-redirectness of the glxgears window (according to a log
message) and apparently not bother doing any further compositing.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-06-18 00:51:19 +02:00
|
|
|
&& (pDraw->height == pPriv->height);
|
2009-04-09 00:44:34 +02:00
|
|
|
|
2011-02-10 22:27:29 +01:00
|
|
|
buffers = calloc((count + 1), sizeof(buffers[0]));
|
2011-04-12 16:13:28 +02:00
|
|
|
if (!buffers)
|
2012-03-21 20:55:09 +01:00
|
|
|
goto err_out;
|
2009-04-09 00:44:34 +02:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
for (i = 0; i < count; i++) {
|
2012-03-21 20:55:09 +01:00
|
|
|
const unsigned attachment = *(attachments++);
|
|
|
|
const unsigned format = (has_format) ? *(attachments++) : 0;
|
|
|
|
|
|
|
|
if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
|
|
|
|
format, dimensions_match, &buffers[i]))
|
|
|
|
buffers_changed = 1;
|
|
|
|
|
|
|
|
if (buffers[i] == NULL)
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
/* If the drawable is a window and the front-buffer is requested,
|
|
|
|
* silently add the fake front-buffer to the list of requested
|
|
|
|
* attachments. The counting logic in the loop accounts for the case
|
|
|
|
* where the client requests both the fake and real front-buffer.
|
|
|
|
*/
|
|
|
|
if (attachment == DRI2BufferBackLeft) {
|
|
|
|
need_real_front++;
|
|
|
|
front_format = format;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachment == DRI2BufferFrontLeft) {
|
|
|
|
need_real_front--;
|
|
|
|
front_format = format;
|
|
|
|
|
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
need_fake_front++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
if (attachment == DRI2BufferFakeFrontLeft) {
|
|
|
|
need_fake_front--;
|
|
|
|
have_fake_front = 1;
|
|
|
|
}
|
|
|
|
}
|
2009-07-06 20:53:02 +02:00
|
|
|
}
|
2009-07-01 23:01:57 +02:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (need_real_front > 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
|
|
|
|
front_format, dimensions_match,
|
|
|
|
&buffers[i]))
|
|
|
|
buffers_changed = 1;
|
|
|
|
|
|
|
|
if (buffers[i] == NULL)
|
|
|
|
goto err_out;
|
|
|
|
i++;
|
2009-07-06 20:53:02 +02:00
|
|
|
}
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (need_fake_front > 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
|
|
|
|
front_format, dimensions_match,
|
|
|
|
&buffers[i]))
|
|
|
|
buffers_changed = 1;
|
2010-02-24 23:18:01 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (buffers[i] == NULL)
|
|
|
|
goto err_out;
|
2010-05-14 15:25:43 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
i++;
|
|
|
|
have_fake_front = 1;
|
2009-07-06 20:53:02 +02:00
|
|
|
}
|
2009-04-24 21:49:19 +02:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
*out_count = i;
|
2009-04-24 21:49:19 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width,
|
|
|
|
height);
|
2009-04-09 23:38:24 +02:00
|
|
|
|
|
|
|
/* If the client is getting a fake front-buffer, pre-fill it with the
|
|
|
|
* contents of the real front-buffer. This ensures correct operation of
|
|
|
|
* applications that call glXWaitX before calling glDrawBuffer.
|
|
|
|
*/
|
2010-02-24 23:18:01 +01:00
|
|
|
if (have_fake_front && buffers_changed) {
|
2012-03-21 20:55:09 +01:00
|
|
|
BoxRec box;
|
|
|
|
RegionRec region;
|
2009-04-09 23:38:24 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pPriv->width;
|
|
|
|
box.y2 = pPriv->height;
|
|
|
|
RegionInit(®ion, &box, 0);
|
2009-04-09 23:38:24 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft,
|
|
|
|
DRI2BufferFrontLeft);
|
2009-04-09 23:38:24 +02:00
|
|
|
}
|
|
|
|
|
2011-05-06 17:18:15 +02:00
|
|
|
pPriv->needInvalidate = TRUE;
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
return pPriv->buffers;
|
2010-05-14 15:25:43 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
err_out:
|
2010-05-14 15:25:43 +02:00
|
|
|
|
|
|
|
*out_count = 0;
|
|
|
|
|
2011-04-12 16:13:28 +02:00
|
|
|
if (buffers) {
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
if (buffers[i] != NULL)
|
2012-06-26 11:20:52 +02:00
|
|
|
destroy_buffer(pDraw, buffers[i], 0);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2010-05-14 15:25:43 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
free(buffers);
|
|
|
|
buffers = NULL;
|
2011-04-12 16:13:28 +02:00
|
|
|
}
|
2010-05-14 15:25:43 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width,
|
|
|
|
height);
|
2010-05-14 15:25:43 +02:00
|
|
|
|
|
|
|
return buffers;
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
DRI2BufferPtr *
|
2009-04-24 21:49:19 +02:00
|
|
|
DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned int *attachments, int count, int *out_count)
|
2009-04-24 21:49:19 +02:00
|
|
|
{
|
|
|
|
return do_get_buffers(pDraw, width, height, attachments, count,
|
2012-03-21 20:55:09 +01:00
|
|
|
out_count, FALSE);
|
2009-04-24 21:49:19 +02:00
|
|
|
}
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
DRI2BufferPtr *
|
2009-04-24 21:49:19 +02:00
|
|
|
DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned int *attachments, int count, int *out_count)
|
2009-04-24 21:49:19 +02:00
|
|
|
{
|
|
|
|
return do_get_buffers(pDraw, width, height, attachments, count,
|
2012-03-21 20:55:09 +01:00
|
|
|
out_count, TRUE);
|
2009-04-24 21:49:19 +02:00
|
|
|
}
|
|
|
|
|
2010-05-11 16:52:18 +02:00
|
|
|
static void
|
|
|
|
DRI2InvalidateDrawable(DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
DRI2DrawableRefPtr ref;
|
|
|
|
|
2011-05-06 17:18:15 +02:00
|
|
|
if (!pPriv || !pPriv->needInvalidate)
|
2010-05-11 16:52:18 +02:00
|
|
|
return;
|
|
|
|
|
2011-05-06 17:18:15 +02:00
|
|
|
pPriv->needInvalidate = FALSE;
|
|
|
|
|
2012-01-27 01:41:25 +01:00
|
|
|
xorg_list_for_each_entry(ref, &pPriv->reference_list, link)
|
2012-03-21 20:55:09 +01:00
|
|
|
ref->invalidate(pDraw, ref->priv, ref->id);
|
2010-05-11 16:52:18 +02:00
|
|
|
}
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
/*
|
|
|
|
* In the direct rendered case, we throttle the clients that have more
|
|
|
|
* than their share of outstanding swaps (and thus busy buffers) when a
|
|
|
|
* new GetBuffers request is received. In the AIGLX case, we allow the
|
|
|
|
* client to get the new buffers, but throttle when the next GLX request
|
|
|
|
* comes in (see __glXDRIcontextWait()).
|
|
|
|
*/
|
|
|
|
Bool
|
|
|
|
DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
/* Throttle to swap limit */
|
2012-03-21 20:55:09 +01:00
|
|
|
if ((pPriv->swapsPending >= pPriv->swap_limit) && !pPriv->blockedClient) {
|
|
|
|
ResetCurrentRequest(client);
|
|
|
|
client->sequence--;
|
|
|
|
IgnoreClient(client);
|
|
|
|
pPriv->blockedClient = client;
|
|
|
|
return TRUE;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-03-09 00:10:47 +01:00
|
|
|
static void
|
|
|
|
__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
|
|
|
|
{
|
|
|
|
if (pPriv->blockedClient == NULL) {
|
2012-03-21 20:55:09 +01:00
|
|
|
IgnoreClient(client);
|
|
|
|
pPriv->blockedClient = client;
|
2010-03-09 00:10:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
void
|
|
|
|
DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2010-03-09 00:10:47 +01:00
|
|
|
__DRI2BlockClient(client, pPriv);
|
|
|
|
pPriv->blockedOnMsc = TRUE;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
static inline PixmapPtr GetDrawablePixmap(DrawablePtr drawable)
|
|
|
|
{
|
|
|
|
if (drawable->type == DRAWABLE_PIXMAP)
|
|
|
|
return (PixmapPtr)drawable;
|
|
|
|
else {
|
|
|
|
struct _Window *pWin = (struct _Window *)drawable;
|
|
|
|
return drawable->pScreen->GetWindowPixmap(pWin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-06 08:33:54 +02:00
|
|
|
/*
|
|
|
|
* A TraverseTree callback to invalidate all windows using the same
|
|
|
|
* pixmap
|
|
|
|
*/
|
|
|
|
static int
|
2013-12-15 10:05:51 +01:00
|
|
|
DRI2InvalidateWalk(WindowPtr pWin, void *data)
|
2012-09-06 08:33:54 +02:00
|
|
|
{
|
|
|
|
if (pWin->drawable.pScreen->GetWindowPixmap(pWin) != data)
|
|
|
|
return WT_DONTWALKCHILDREN;
|
|
|
|
DRI2InvalidateDrawable(&pWin->drawable);
|
|
|
|
return WT_WALKCHILDREN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DRI2InvalidateDrawableAll(DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
WindowPtr pWin = (WindowPtr) pDraw;
|
|
|
|
PixmapPtr pPixmap = pDraw->pScreen->GetWindowPixmap(pWin);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the top-most window using this pixmap
|
|
|
|
*/
|
|
|
|
while (pWin->parent &&
|
|
|
|
pDraw->pScreen->GetWindowPixmap(pWin->parent) == pPixmap)
|
|
|
|
pWin = pWin->parent;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Walk the sub-tree to invalidate all of the
|
|
|
|
* windows using the same pixmap
|
|
|
|
*/
|
|
|
|
TraverseTree(pWin, DRI2InvalidateWalk, pPixmap);
|
|
|
|
DRI2InvalidateDrawable(&pPixmap->drawable);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DRI2InvalidateDrawable(pDraw);
|
|
|
|
}
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
PixmapPtr spix;
|
|
|
|
PixmapPtr mpix = GetDrawablePixmap(pDraw);
|
|
|
|
ScreenPtr master, slave;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
master = mpix->drawable.pScreen;
|
|
|
|
|
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
WindowPtr pWin = (WindowPtr)pDraw;
|
|
|
|
PixmapPtr pPixmap = pDraw->pScreen->GetWindowPixmap(pWin);
|
|
|
|
|
|
|
|
if (pDraw->pScreen->GetScreenPixmap(pDraw->pScreen) == pPixmap) {
|
|
|
|
if (pPriv->redirectpixmap &&
|
|
|
|
pPriv->redirectpixmap->drawable.width == pDraw->width &&
|
|
|
|
pPriv->redirectpixmap->drawable.height == pDraw->height &&
|
|
|
|
pPriv->redirectpixmap->drawable.depth == pDraw->depth) {
|
|
|
|
mpix = pPriv->redirectpixmap;
|
|
|
|
} else {
|
|
|
|
if (master->ReplaceScanoutPixmap) {
|
|
|
|
mpix = (*master->CreatePixmap)(master, pDraw->width, pDraw->height,
|
|
|
|
pDraw->depth, CREATE_PIXMAP_USAGE_SHARED);
|
|
|
|
if (!mpix)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = (*master->ReplaceScanoutPixmap)(pDraw, mpix, TRUE);
|
|
|
|
if (ret == FALSE) {
|
|
|
|
(*master->DestroyPixmap)(mpix);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
pPriv->redirectpixmap = mpix;
|
|
|
|
} else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else if (pPriv->redirectpixmap) {
|
|
|
|
(*master->ReplaceScanoutPixmap)(pDraw, pPriv->redirectpixmap, FALSE);
|
|
|
|
(*master->DestroyPixmap)(pPriv->redirectpixmap);
|
|
|
|
pPriv->redirectpixmap = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
slave = GetScreenPrime(pDraw->pScreen, pPriv->prime_id);
|
|
|
|
|
|
|
|
/* check if the pixmap is still fine */
|
|
|
|
if (pPriv->prime_slave_pixmap) {
|
|
|
|
if (pPriv->prime_slave_pixmap->master_pixmap == mpix)
|
|
|
|
return &pPriv->prime_slave_pixmap->drawable;
|
|
|
|
else {
|
2012-08-03 08:43:22 +02:00
|
|
|
(*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
|
2012-06-26 11:20:52 +02:00
|
|
|
(*slave->DestroyPixmap)(pPriv->prime_slave_pixmap);
|
2012-08-03 08:43:22 +02:00
|
|
|
pPriv->prime_slave_pixmap = NULL;
|
2012-06-26 11:20:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spix = PixmapShareToSlave(mpix, slave);
|
|
|
|
if (!spix)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pPriv->prime_slave_pixmap = spix;
|
|
|
|
#ifdef COMPOSITE
|
|
|
|
spix->screen_x = mpix->screen_x;
|
|
|
|
spix->screen_y = mpix->screen_y;
|
|
|
|
#endif
|
2012-09-06 08:33:54 +02:00
|
|
|
|
|
|
|
DRI2InvalidateDrawableAll(pDraw);
|
2012-06-26 11:20:52 +02:00
|
|
|
return &spix->drawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
|
|
|
|
DRI2BufferPtr pDest, DRI2BufferPtr pSrc)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
DRI2ScreenPtr ds;
|
|
|
|
ScreenPtr primeScreen;
|
|
|
|
|
|
|
|
primeScreen = GetScreenPrime(pDraw->pScreen, pPriv->prime_id);
|
|
|
|
ds = DRI2GetScreen(primeScreen);
|
|
|
|
|
|
|
|
if (ds->CopyRegion2)
|
|
|
|
(*ds->CopyRegion2)(primeScreen, pDraw, pRegion, pDest, pSrc);
|
|
|
|
else
|
|
|
|
(*ds->CopyRegion) (pDraw, pRegion, pDest, pSrc);
|
|
|
|
|
|
|
|
/* cause damage to the box */
|
|
|
|
if (pPriv->prime_id) {
|
|
|
|
BoxRec box;
|
|
|
|
RegionRec region;
|
|
|
|
box.x1 = 0;
|
|
|
|
box.x2 = box.x1 + pDraw->width;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.y2 = box.y1 + pDraw->height;
|
|
|
|
RegionInit(®ion, &box, 1);
|
|
|
|
RegionTranslate(®ion, pDraw->x, pDraw->y);
|
|
|
|
DamageRegionAppend(pDraw, ®ion);
|
|
|
|
DamageRegionProcessPending(pDraw);
|
|
|
|
RegionUninit(®ion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2008-10-07 19:49:28 +02:00
|
|
|
DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned int dest, unsigned int src)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2008-08-11 22:59:17 +02:00
|
|
|
DRI2DrawablePtr pPriv;
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2BufferPtr pDestBuffer, pSrcBuffer;
|
|
|
|
int i;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadDrawable;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-10-07 19:49:28 +02:00
|
|
|
pDestBuffer = NULL;
|
2008-08-11 22:59:17 +02:00
|
|
|
pSrcBuffer = NULL;
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 0; i < pPriv->bufferCount; i++) {
|
|
|
|
if (pPriv->buffers[i]->attachment == dest)
|
|
|
|
pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
|
|
|
|
if (pPriv->buffers[i]->attachment == src)
|
|
|
|
pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
2008-10-07 19:49:28 +02:00
|
|
|
if (pSrcBuffer == NULL || pDestBuffer == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadValue;
|
2009-07-01 23:01:57 +02:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
dri2_copy_region(pDraw, pRegion, pDestBuffer, pSrcBuffer);
|
2008-10-07 19:49:28 +02:00
|
|
|
|
|
|
|
return Success;
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
/* Can this drawable be page flipped? */
|
|
|
|
Bool
|
|
|
|
DRI2CanFlip(DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
WindowPtr pWin, pRoot;
|
|
|
|
PixmapPtr pWinPixmap, pRootPixmap;
|
|
|
|
|
|
|
|
if (pDraw->type == DRAWABLE_PIXMAP)
|
2012-03-21 20:55:09 +01:00
|
|
|
return TRUE;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2010-05-22 09:26:28 +02:00
|
|
|
pRoot = pScreen->root;
|
2009-07-16 15:01:17 +02:00
|
|
|
pRootPixmap = pScreen->GetWindowPixmap(pRoot);
|
|
|
|
|
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
pWinPixmap = pScreen->GetWindowPixmap(pWin);
|
|
|
|
if (pRootPixmap != pWinPixmap)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2010-05-22 00:05:48 +02:00
|
|
|
if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2010-12-03 16:42:16 +01:00
|
|
|
/* Does the window match the pixmap exactly? */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pDraw->x != 0 || pDraw->y != 0 ||
|
2010-12-03 16:42:16 +01:00
|
|
|
#ifdef COMPOSITE
|
2012-03-21 20:55:09 +01:00
|
|
|
pDraw->x != pWinPixmap->screen_x || pDraw->y != pWinPixmap->screen_y ||
|
2010-12-03 16:42:16 +01:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
pDraw->width != pWinPixmap->drawable.width ||
|
|
|
|
pDraw->height != pWinPixmap->drawable.height)
|
|
|
|
return FALSE;
|
2010-12-03 16:42:16 +01:00
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Can we do a pixmap exchange instead of a blit? */
|
|
|
|
Bool
|
|
|
|
DRI2CanExchange(DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned int tv_sec, unsigned int tv_usec)
|
2009-07-16 15:01:17 +02:00
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ProcDRI2WaitMSCReply(client, ((CARD64) tv_sec * 1000000) + tv_usec,
|
|
|
|
frame, pPriv->swap_count);
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
if (pPriv->blockedClient)
|
2012-03-21 20:55:09 +01:00
|
|
|
AttendClient(pPriv->blockedClient);
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
pPriv->blockedClient = NULL;
|
2010-03-09 00:10:47 +01:00
|
|
|
pPriv->blockedOnMsc = FALSE;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned int tv_sec, unsigned int tv_usec)
|
2009-07-16 15:01:17 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
2009-07-16 15:01:17 +02:00
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-03-09 00:10:47 +01:00
|
|
|
* Swap completed.
|
|
|
|
* Wake the client iff:
|
|
|
|
* - it was waiting on SBC
|
|
|
|
* - was blocked due to GLX make current
|
|
|
|
* - was blocked due to swap throttling
|
|
|
|
* - is not blocked due to an MSC wait
|
2009-07-16 15:01:17 +02:00
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pPriv->target_sbc != -1 && pPriv->target_sbc <= pPriv->swap_count) {
|
|
|
|
ProcDRI2WaitMSCReply(client, ((CARD64) tv_sec * 1000000) + tv_usec,
|
|
|
|
frame, pPriv->swap_count);
|
|
|
|
pPriv->target_sbc = -1;
|
|
|
|
|
|
|
|
AttendClient(pPriv->blockedClient);
|
|
|
|
pPriv->blockedClient = NULL;
|
|
|
|
}
|
|
|
|
else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
|
|
|
|
if (pPriv->blockedClient) {
|
|
|
|
AttendClient(pPriv->blockedClient);
|
|
|
|
pPriv->blockedClient = NULL;
|
|
|
|
}
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
|
2012-03-21 20:55:09 +01:00
|
|
|
unsigned int tv_sec, unsigned int tv_usec, int type,
|
|
|
|
DRI2SwapEventPtr swap_complete, void *swap_data)
|
2009-07-16 15:01:17 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
2009-07-16 15:01:17 +02:00
|
|
|
DRI2DrawablePtr pPriv;
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD64 ust = 0;
|
|
|
|
BoxRec box;
|
|
|
|
RegionRec region;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
2010-02-21 05:25:59 +01:00
|
|
|
pPriv->swapsPending--;
|
|
|
|
pPriv->swap_count++;
|
|
|
|
|
2010-05-10 14:36:02 +02:00
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pDraw->width;
|
|
|
|
box.y2 = pDraw->height;
|
2010-05-22 00:05:48 +02:00
|
|
|
RegionInit(®ion, &box, 0);
|
2010-05-10 14:36:02 +02:00
|
|
|
DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft,
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2BufferFrontLeft);
|
2010-05-10 14:36:02 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ust = ((CARD64) tv_sec * 1000000) + tv_usec;
|
2009-07-16 15:01:17 +02:00
|
|
|
if (swap_complete)
|
2012-03-21 20:55:09 +01:00
|
|
|
swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
|
2009-07-16 15:01:17 +02:00
|
|
|
|
DRI2WaitSbc(): Fixes for correct semantic of glXWaitForSbcOML()
Added implementation for case target_sbc == 0. In that case, the
function shall schedule a wait until all pending swaps for the drawable
have completed.
Fix for non-blocking case. Old implementation returned random,
uninitialized values for (ust,msc,sbc) if it returned immediately
without scheduling a wait due to sbc >= target_sbc.
Now if function doesn't schedule a wait, but returns immediately,
it returns the (ust,msc,sbc) of the most recently completed swap,
i.e., the UST and MSC corresponding to the time when the returned
current SBC was reached.
Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
2010-02-21 05:26:00 +01:00
|
|
|
pPriv->last_swap_msc = frame;
|
|
|
|
pPriv->last_swap_ust = ust;
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
|
|
|
|
|
|
|
|
/* If we're currently waiting for a swap on this drawable, reset
|
|
|
|
* the request and suspend the client. We only support one
|
|
|
|
* blocked client per drawable. */
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pPriv && pPriv->swapsPending && pPriv->blockedClient == NULL) {
|
|
|
|
ResetCurrentRequest(client);
|
|
|
|
client->sequence--;
|
|
|
|
__DRI2BlockClient(client, pPriv);
|
|
|
|
return TRUE;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-09-06 08:33:54 +02:00
|
|
|
|
2011-12-18 17:29:40 +01:00
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
int
|
|
|
|
DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD64 divisor, CARD64 remainder, CARD64 * swap_target,
|
|
|
|
DRI2SwapEventPtr func, void *data)
|
2009-07-16 15:01:17 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
2009-07-16 15:01:17 +02:00
|
|
|
DRI2DrawablePtr pPriv;
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
|
|
|
|
int ret, i;
|
|
|
|
CARD64 ust, current_msc;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
2014-04-18 21:22:19 +02:00
|
|
|
/* According to spec, return expected swapbuffers count SBC after this swap
|
|
|
|
* will complete. This is ignored unless we return Success, but it must be
|
|
|
|
* initialized on every path where we return Success or the caller will send
|
|
|
|
* an uninitialized value off the stack to the client. So let's initialize
|
|
|
|
* it as early as possible, just to be sure.
|
|
|
|
*/
|
|
|
|
*swap_target = pPriv->swap_count + pPriv->swapsPending + 1;
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
for (i = 0; i < pPriv->bufferCount; i++) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
|
|
|
|
pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
|
|
|
|
if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
|
|
|
|
pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
if (pSrcBuffer == NULL || pDestBuffer == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] %s: drawable has no back or front?\n", __func__);
|
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
2010-03-05 18:49:03 +01:00
|
|
|
/* Old DDX or no swap interval, just blit */
|
2012-06-26 11:20:52 +02:00
|
|
|
if (!ds->ScheduleSwap || !pPriv->swap_interval || pPriv->prime_id) {
|
2012-03-21 20:55:09 +01:00
|
|
|
BoxRec box;
|
|
|
|
RegionRec region;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pDraw->width;
|
|
|
|
box.y2 = pDraw->height;
|
|
|
|
RegionInit(®ion, &box, 0);
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
pPriv->swapsPending++;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
dri2_copy_region(pDraw, ®ion, pDestBuffer, pSrcBuffer);
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
|
|
|
|
func, data);
|
|
|
|
return Success;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-03-04 19:31:59 +01:00
|
|
|
* In the simple glXSwapBuffers case, all params will be 0, and we just
|
|
|
|
* need to schedule a swap for the last swap target + the swap interval.
|
2009-07-16 15:01:17 +02:00
|
|
|
*/
|
2010-03-04 19:31:59 +01:00
|
|
|
if (target_msc == 0 && divisor == 0 && remainder == 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/* If the current vblank count of the drawable's crtc is lower
|
|
|
|
* than the count stored in last_swap_target from a previous swap
|
|
|
|
* then reinitialize last_swap_target to the current crtc's msc,
|
|
|
|
* otherwise the swap will hang. This will happen if the drawable
|
|
|
|
* is moved to a crtc with a lower refresh rate, or a crtc that just
|
|
|
|
* got enabled.
|
|
|
|
*/
|
|
|
|
if (ds->GetMSC) {
|
|
|
|
if (!(*ds->GetMSC) (pDraw, &ust, ¤t_msc))
|
|
|
|
pPriv->last_swap_target = 0;
|
|
|
|
|
|
|
|
if (current_msc < pPriv->last_swap_target)
|
|
|
|
pPriv->last_swap_target = current_msc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Swap target for this swap is last swap target + swap interval since
|
|
|
|
* we have to account for the current swap count, interval, and the
|
|
|
|
* number of pending swaps.
|
|
|
|
*/
|
2014-04-18 21:22:18 +02:00
|
|
|
target_msc = pPriv->last_swap_target + pPriv->swap_interval;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
}
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2010-03-08 21:41:25 +01:00
|
|
|
pPriv->swapsPending++;
|
2012-03-21 20:55:09 +01:00
|
|
|
ret = (*ds->ScheduleSwap) (client, pDraw, pDestBuffer, pSrcBuffer,
|
2014-04-18 21:22:18 +02:00
|
|
|
&target_msc, divisor, remainder, func, data);
|
2009-07-16 15:01:17 +02:00
|
|
|
if (!ret) {
|
2012-03-21 20:55:09 +01:00
|
|
|
pPriv->swapsPending--; /* didn't schedule */
|
2009-07-16 15:01:17 +02:00
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] %s: driver failed to schedule swap\n", __func__);
|
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
2014-04-18 21:22:18 +02:00
|
|
|
pPriv->last_swap_target = target_msc;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2012-09-06 08:33:54 +02:00
|
|
|
DRI2InvalidateDrawableAll(pDraw);
|
2010-05-11 16:52:18 +02:00
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DRI2SwapInterval(DrawablePtr pDrawable, int interval)
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
ScreenPtr pScreen = pDrawable->pScreen;
|
2009-07-16 15:01:17 +02:00
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
|
|
|
|
|
2010-03-05 18:15:24 +01:00
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return;
|
2010-03-05 18:15:24 +01:00
|
|
|
}
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2010-03-05 18:15:24 +01:00
|
|
|
/* fixme: check against arbitrary max? */
|
2009-07-16 15:01:17 +02:00
|
|
|
pPriv->swap_interval = interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2GetMSC(DrawablePtr pDraw, CARD64 * ust, CARD64 * msc, CARD64 * sbc)
|
2009-07-16 15:01:17 +02:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ds->GetMSC) {
|
2012-03-21 20:55:09 +01:00
|
|
|
*ust = 0;
|
|
|
|
*msc = 0;
|
|
|
|
*sbc = pPriv->swap_count;
|
|
|
|
return Success;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Spec needs to be updated to include unmapped or redirected
|
|
|
|
* drawables
|
|
|
|
*/
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ret = (*ds->GetMSC) (pDraw, ust, msc);
|
2009-07-16 15:01:17 +02:00
|
|
|
if (!ret)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
*sbc = pPriv->swap_count;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
|
2012-03-21 20:55:09 +01:00
|
|
|
CARD64 divisor, CARD64 remainder)
|
2009-07-16 15:01:17 +02:00
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
2010-04-16 11:55:34 +02:00
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
/* Old DDX just completes immediately */
|
|
|
|
if (!ds->ScheduleWaitMSC) {
|
2012-03-21 20:55:09 +01:00
|
|
|
DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
|
2009-07-16 15:01:17 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
return Success;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ret =
|
|
|
|
(*ds->ScheduleWaitMSC) (client, pDraw, target_msc, divisor, remainder);
|
2009-07-16 15:01:17 +02:00
|
|
|
if (!ret)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2010-06-05 13:09:28 +02:00
|
|
|
DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
|
2009-07-16 15:01:17 +02:00
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
2010-04-16 11:55:34 +02:00
|
|
|
if (pPriv == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return BadDrawable;
|
2009-07-16 15:01:17 +02:00
|
|
|
|
DRI2WaitSbc(): Fixes for correct semantic of glXWaitForSbcOML()
Added implementation for case target_sbc == 0. In that case, the
function shall schedule a wait until all pending swaps for the drawable
have completed.
Fix for non-blocking case. Old implementation returned random,
uninitialized values for (ust,msc,sbc) if it returned immediately
without scheduling a wait due to sbc >= target_sbc.
Now if function doesn't schedule a wait, but returns immediately,
it returns the (ust,msc,sbc) of the most recently completed swap,
i.e., the UST and MSC corresponding to the time when the returned
current SBC was reached.
Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
2010-02-21 05:26:00 +01:00
|
|
|
/* target_sbc == 0 means to block until all pending swaps are
|
|
|
|
* finished. Recalculate target_sbc to get that behaviour.
|
|
|
|
*/
|
|
|
|
if (target_sbc == 0)
|
|
|
|
target_sbc = pPriv->swap_count + pPriv->swapsPending;
|
|
|
|
|
2010-06-05 13:09:28 +02:00
|
|
|
/* If current swap count already >= target_sbc, reply and
|
DRI2WaitSbc(): Fixes for correct semantic of glXWaitForSbcOML()
Added implementation for case target_sbc == 0. In that case, the
function shall schedule a wait until all pending swaps for the drawable
have completed.
Fix for non-blocking case. Old implementation returned random,
uninitialized values for (ust,msc,sbc) if it returned immediately
without scheduling a wait due to sbc >= target_sbc.
Now if function doesn't schedule a wait, but returns immediately,
it returns the (ust,msc,sbc) of the most recently completed swap,
i.e., the UST and MSC corresponding to the time when the returned
current SBC was reached.
Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
2010-02-21 05:26:00 +01:00
|
|
|
* return immediately with (ust, msc, sbc) triplet of
|
|
|
|
* most recent completed swap.
|
|
|
|
*/
|
|
|
|
if (pPriv->swap_count >= target_sbc) {
|
2010-06-05 13:09:28 +02:00
|
|
|
ProcDRI2WaitMSCReply(client, pPriv->last_swap_ust,
|
|
|
|
pPriv->last_swap_msc, pPriv->swap_count);
|
DRI2WaitSbc(): Fixes for correct semantic of glXWaitForSbcOML()
Added implementation for case target_sbc == 0. In that case, the
function shall schedule a wait until all pending swaps for the drawable
have completed.
Fix for non-blocking case. Old implementation returned random,
uninitialized values for (ust,msc,sbc) if it returned immediately
without scheduling a wait due to sbc >= target_sbc.
Now if function doesn't schedule a wait, but returns immediately,
it returns the (ust,msc,sbc) of the most recently completed swap,
i.e., the UST and MSC corresponding to the time when the returned
current SBC was reached.
Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
2010-02-21 05:26:00 +01:00
|
|
|
return Success;
|
|
|
|
}
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
pPriv->target_sbc = target_sbc;
|
2010-03-09 00:10:47 +01:00
|
|
|
__DRI2BlockClient(client, pPriv);
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2010-03-23 17:47:08 +01:00
|
|
|
Bool
|
|
|
|
DRI2HasSwapControl(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
|
|
|
|
|
2010-06-06 16:18:40 +02:00
|
|
|
return ds->ScheduleSwap && ds->GetMSC;
|
2010-03-23 17:47:08 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-06-26 11:20:52 +02:00
|
|
|
DRI2Connect(ClientPtr client, ScreenPtr pScreen,
|
|
|
|
unsigned int driverType, int *fd,
|
2012-03-21 20:55:09 +01:00
|
|
|
const char **driverName, const char **deviceName)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2010-06-08 01:28:34 +02:00
|
|
|
DRI2ScreenPtr ds;
|
2012-06-26 11:20:52 +02:00
|
|
|
uint32_t prime_id = DRI2DriverPrimeId(driverType);
|
|
|
|
uint32_t driver_id = driverType & 0xffff;
|
2010-06-08 01:28:34 +02:00
|
|
|
|
|
|
|
if (!dixPrivateKeyRegistered(dri2ScreenPrivateKey))
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
ds = DRI2GetScreenPrime(pScreen, prime_id);
|
|
|
|
if (ds == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
if (driver_id >= ds->numDrivers ||
|
|
|
|
!ds->driverNames[driver_id])
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*driverName = ds->driverNames[driver_id];
|
2008-10-07 19:49:28 +02:00
|
|
|
*deviceName = ds->deviceName;
|
2012-06-26 11:20:52 +02:00
|
|
|
*fd = ds->fd;
|
|
|
|
|
|
|
|
if (client) {
|
|
|
|
DRI2ClientPtr dri2_client;
|
|
|
|
dri2_client = dri2ClientPrivate(client);
|
|
|
|
dri2_client->prime_id = prime_id;
|
|
|
|
}
|
2008-02-04 17:58:24 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-28 04:07:11 +02:00
|
|
|
static int
|
2012-06-20 05:53:53 +02:00
|
|
|
DRI2AuthMagic (ScreenPtr pScreen, uint32_t magic)
|
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
|
2012-06-28 04:07:11 +02:00
|
|
|
if (ds == NULL)
|
|
|
|
return -EINVAL;
|
2012-06-20 05:53:53 +02:00
|
|
|
|
2012-06-28 04:07:11 +02:00
|
|
|
return (*ds->LegacyAuthMagic) (ds->fd, magic);
|
2012-06-20 05:53:53 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-06-26 11:20:52 +02:00
|
|
|
DRI2Authenticate(ClientPtr client, ScreenPtr pScreen, uint32_t magic)
|
2008-03-11 05:35:31 +01:00
|
|
|
{
|
2012-06-26 11:20:52 +02:00
|
|
|
DRI2ScreenPtr ds;
|
|
|
|
DRI2ClientPtr dri2_client = dri2ClientPrivate(client);
|
|
|
|
ScreenPtr primescreen;
|
2008-03-11 05:35:31 +01:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
ds = DRI2GetScreenPrime(pScreen, dri2_client->prime_id);
|
|
|
|
if (ds == NULL)
|
2010-01-22 16:58:17 +01:00
|
|
|
return FALSE;
|
2008-03-11 05:35:31 +01:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
primescreen = GetScreenPrime(pScreen, dri2_client->prime_id);
|
|
|
|
if ((*ds->AuthMagic)(primescreen, magic))
|
|
|
|
return FALSE;
|
2008-03-11 05:35:31 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
composite: use config notify hook to do pixmap resize.
Since reallocating the backing pixmap can fail, we need to try and do
it before any other side effects of reconfiguring the window happen.
This changes the ConfigNotify hook to return status, and moves the
composite window reconfiguration wrappers to ConfigNotify. They all
basically did the same thing, so we can drop the MoveWindow,
ResizeWindow, ChangeBorderWidth wrappers, and allow ConfigNotify to do
all the work. If reallocation fails we fail before we send any
confiureNotify events, or enter the area we can't recover from.
The only place we now enforce 32k limits are in EXA/UXA/fb, so drivers
that don't use this should probably deal with it in their pixmap
allocate if they don't already.
This also breaks ABI, so we need an alternate fix for older servers,
working on the X server makes me realise why I'm a kernel hacker.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-04 03:09:46 +02:00
|
|
|
static int
|
2010-05-11 16:52:18 +02:00
|
|
|
DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
|
2012-03-21 20:55:09 +01:00
|
|
|
WindowPtr pSib)
|
2010-05-11 16:52:18 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
DrawablePtr pDraw = (DrawablePtr) pWin;
|
2010-05-11 16:52:18 +02:00
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
|
|
|
|
DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
|
composite: use config notify hook to do pixmap resize.
Since reallocating the backing pixmap can fail, we need to try and do
it before any other side effects of reconfiguring the window happen.
This changes the ConfigNotify hook to return status, and moves the
composite window reconfiguration wrappers to ConfigNotify. They all
basically did the same thing, so we can drop the MoveWindow,
ResizeWindow, ChangeBorderWidth wrappers, and allow ConfigNotify to do
all the work. If reallocation fails we fail before we send any
confiureNotify events, or enter the area we can't recover from.
The only place we now enforce 32k limits are in EXA/UXA/fb, so drivers
that don't use this should probably deal with it in their pixmap
allocate if they don't already.
This also breaks ABI, so we need an alternate fix for older servers,
working on the X server makes me realise why I'm a kernel hacker.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-04 03:09:46 +02:00
|
|
|
int ret;
|
2010-05-11 16:52:18 +02:00
|
|
|
|
|
|
|
if (ds->ConfigNotify) {
|
2012-03-21 20:55:09 +01:00
|
|
|
pScreen->ConfigNotify = ds->ConfigNotify;
|
2010-05-11 16:52:18 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ret = (*pScreen->ConfigNotify) (pWin, x, y, w, h, bw, pSib);
|
2010-05-11 16:52:18 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ds->ConfigNotify = pScreen->ConfigNotify;
|
|
|
|
pScreen->ConfigNotify = DRI2ConfigNotify;
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2010-05-11 16:52:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!dd || (dd->width == w && dd->height == h))
|
2012-03-21 20:55:09 +01:00
|
|
|
return Success;
|
2010-05-11 16:52:18 +02:00
|
|
|
|
|
|
|
DRI2InvalidateDrawable(pDraw);
|
composite: use config notify hook to do pixmap resize.
Since reallocating the backing pixmap can fail, we need to try and do
it before any other side effects of reconfiguring the window happen.
This changes the ConfigNotify hook to return status, and moves the
composite window reconfiguration wrappers to ConfigNotify. They all
basically did the same thing, so we can drop the MoveWindow,
ResizeWindow, ChangeBorderWidth wrappers, and allow ConfigNotify to do
all the work. If reallocation fails we fail before we send any
confiureNotify events, or enter the area we can't recover from.
The only place we now enforce 32k limits are in EXA/UXA/fb, so drivers
that don't use this should probably deal with it in their pixmap
allocate if they don't already.
This also breaks ABI, so we need an alternate fix for older servers,
working on the X server makes me realise why I'm a kernel hacker.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-04 03:09:46 +02:00
|
|
|
return Success;
|
2010-05-11 16:52:18 +02:00
|
|
|
}
|
|
|
|
|
2012-07-07 11:10:08 +02:00
|
|
|
#define MAX_PRIME DRI2DriverPrimeMask
|
|
|
|
static int
|
|
|
|
get_prime_id(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
/* start at 1, prime id 0 is just normal driver */
|
|
|
|
for (i = 1; i < MAX_PRIME; i++) {
|
|
|
|
if (prime_id_allocate_bitmask & (1 << i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
prime_id_allocate_bitmask |= (1 << i);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2008-02-04 17:58:24 +01:00
|
|
|
DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
|
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
const char *driverTypeNames[] = {
|
|
|
|
"DRI", /* DRI2DriverDRI */
|
|
|
|
"VDPAU", /* DRI2DriverVDPAU */
|
2010-01-13 20:35:52 +01:00
|
|
|
};
|
|
|
|
unsigned int i;
|
2010-03-08 21:38:37 +01:00
|
|
|
CARD8 cur_minor;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (info->version < 3)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2009-07-06 20:53:02 +02:00
|
|
|
|
2009-08-28 03:39:42 +02:00
|
|
|
if (!xf86VGAarbiterAllowDRI(pScreen)) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_WARNING,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
|
2009-08-28 03:39:42 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2010-04-27 02:22:21 +02:00
|
|
|
|
|
|
|
if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2010-04-27 02:22:21 +02:00
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
if (!dixRegisterPrivateKey(&dri2ClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(DRI2ClientRec)))
|
|
|
|
return FALSE;
|
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
ds = calloc(1, sizeof *ds);
|
2008-02-04 17:58:24 +01:00
|
|
|
if (!ds)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ds->screen = pScreen;
|
|
|
|
ds->fd = info->fd;
|
|
|
|
ds->deviceName = info->deviceName;
|
|
|
|
dri2_major = 1;
|
2009-07-01 23:01:57 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
ds->CreateBuffer = info->CreateBuffer;
|
|
|
|
ds->DestroyBuffer = info->DestroyBuffer;
|
|
|
|
ds->CopyRegion = info->CopyRegion;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
if (info->version >= 4) {
|
2012-03-21 20:55:09 +01:00
|
|
|
ds->ScheduleSwap = info->ScheduleSwap;
|
|
|
|
ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
|
|
|
|
ds->GetMSC = info->GetMSC;
|
|
|
|
cur_minor = 3;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cur_minor = 1;
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
2012-06-20 05:53:53 +02:00
|
|
|
if (info->version >= 8) {
|
|
|
|
ds->AuthMagic = info->AuthMagic2;
|
|
|
|
}
|
2010-01-22 16:58:17 +01:00
|
|
|
if (info->version >= 5) {
|
2012-06-20 05:53:53 +02:00
|
|
|
ds->LegacyAuthMagic = info->AuthMagic;
|
2010-01-22 16:58:17 +01:00
|
|
|
}
|
|
|
|
|
2010-11-01 15:02:11 +01:00
|
|
|
if (info->version >= 6) {
|
2012-03-21 20:55:09 +01:00
|
|
|
ds->ReuseBufferNotify = info->ReuseBufferNotify;
|
|
|
|
ds->SwapLimitValidate = info->SwapLimitValidate;
|
2010-11-01 15:02:11 +01:00
|
|
|
}
|
2010-11-01 15:21:59 +01:00
|
|
|
|
2012-05-03 01:18:49 +02:00
|
|
|
if (info->version >= 7) {
|
|
|
|
ds->GetParam = info->GetParam;
|
|
|
|
cur_minor = 4;
|
|
|
|
}
|
|
|
|
|
2012-06-26 11:20:52 +02:00
|
|
|
if (info->version >= 9) {
|
|
|
|
ds->CreateBuffer2 = info->CreateBuffer2;
|
2012-07-07 11:10:08 +02:00
|
|
|
if (info->CreateBuffer2 && pScreen->isGPU) {
|
|
|
|
ds->prime_id = get_prime_id();
|
|
|
|
if (ds->prime_id == -1) {
|
|
|
|
free(ds);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-06-26 11:20:52 +02:00
|
|
|
ds->DestroyBuffer2 = info->DestroyBuffer2;
|
|
|
|
ds->CopyRegion2 = info->CopyRegion2;
|
|
|
|
}
|
|
|
|
|
2010-01-22 17:34:36 +01:00
|
|
|
/*
|
|
|
|
* if the driver doesn't provide an AuthMagic function or the info struct
|
2012-06-20 05:53:53 +02:00
|
|
|
* version is too low, call through LegacyAuthMagic
|
2010-01-22 17:34:36 +01:00
|
|
|
*/
|
2012-06-20 05:53:53 +02:00
|
|
|
if (!ds->AuthMagic) {
|
|
|
|
ds->AuthMagic = DRI2AuthMagic;
|
|
|
|
/*
|
|
|
|
* If the driver doesn't provide an AuthMagic function
|
|
|
|
* it relies on the old method (using libdrm) or fails
|
|
|
|
*/
|
|
|
|
if (!ds->LegacyAuthMagic)
|
2010-01-22 17:34:36 +01:00
|
|
|
#ifdef WITH_LIBDRM
|
2012-06-20 05:53:53 +02:00
|
|
|
ds->LegacyAuthMagic = drmAuthMagic;
|
2010-01-22 17:34:36 +01:00
|
|
|
#else
|
2012-06-20 05:53:53 +02:00
|
|
|
goto err_out;
|
2010-01-22 17:34:36 +01:00
|
|
|
#endif
|
2012-06-20 05:53:53 +02:00
|
|
|
}
|
2010-01-22 16:58:17 +01:00
|
|
|
|
2010-03-08 21:38:37 +01:00
|
|
|
/* Initialize minor if needed and set to minimum provied by DDX */
|
|
|
|
if (!dri2_minor || dri2_minor > cur_minor)
|
2012-03-21 20:55:09 +01:00
|
|
|
dri2_minor = cur_minor;
|
2010-03-08 21:38:37 +01:00
|
|
|
|
2010-01-13 20:35:52 +01:00
|
|
|
if (info->version == 3 || info->numDrivers == 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Driver too old: use the old-style driverName field */
|
|
|
|
ds->numDrivers = 1;
|
|
|
|
ds->driverNames = malloc(sizeof(*ds->driverNames));
|
|
|
|
if (!ds->driverNames)
|
|
|
|
goto err_out;
|
|
|
|
ds->driverNames[0] = info->driverName;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ds->numDrivers = info->numDrivers;
|
|
|
|
ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
|
|
|
|
if (!ds->driverNames)
|
|
|
|
goto err_out;
|
|
|
|
memcpy(ds->driverNames, info->driverNames,
|
|
|
|
info->numDrivers * sizeof(*ds->driverNames));
|
2010-01-13 20:35:52 +01:00
|
|
|
}
|
|
|
|
|
2008-02-04 17:58:24 +01:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
|
|
|
|
|
2010-05-11 16:52:18 +02:00
|
|
|
ds->ConfigNotify = pScreen->ConfigNotify;
|
|
|
|
pScreen->ConfigNotify = DRI2ConfigNotify;
|
|
|
|
|
2008-02-04 17:58:24 +01:00
|
|
|
xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
|
2010-01-13 20:35:52 +01:00
|
|
|
for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
|
2012-03-21 20:55:09 +01:00
|
|
|
if (i < ds->numDrivers && ds->driverNames[i]) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
|
|
|
|
driverTypeNames[i], ds->driverNames[i]);
|
|
|
|
}
|
2010-01-13 20:35:52 +01:00
|
|
|
}
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
return TRUE;
|
2010-01-22 17:34:36 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
err_out:
|
2010-01-22 17:34:36 +01:00
|
|
|
xf86DrvMsg(pScreen->myNum, X_WARNING,
|
2012-03-21 20:55:09 +01:00
|
|
|
"[DRI2] Initialization failed for info version %d.\n",
|
|
|
|
info->version);
|
2010-01-22 17:34:36 +01:00
|
|
|
free(ds);
|
|
|
|
return FALSE;
|
2008-08-11 22:59:17 +02:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2008-08-11 22:59:17 +02:00
|
|
|
DRI2CloseScreen(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2011-06-07 21:22:15 +02:00
|
|
|
pScreen->ConfigNotify = ds->ConfigNotify;
|
2008-08-11 22:59:17 +02:00
|
|
|
|
2012-07-07 11:10:08 +02:00
|
|
|
if (ds->prime_id)
|
|
|
|
prime_id_allocate_bitmask &= ~(1 << ds->prime_id);
|
2010-05-05 20:44:06 +02:00
|
|
|
free(ds->driverNames);
|
|
|
|
free(ds);
|
2008-08-11 22:59:17 +02:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2011-08-25 17:04:04 +02:00
|
|
|
/* Called by InitExtensions() */
|
|
|
|
Bool
|
|
|
|
DRI2ModuleSetup(void)
|
|
|
|
{
|
|
|
|
dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
|
|
|
|
if (!dri2DrawableRes)
|
2012-03-21 20:55:09 +01:00
|
|
|
return FALSE;
|
2011-08-25 17:04:04 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-03-27 00:28:09 +01:00
|
|
|
|
2009-04-24 21:09:21 +02:00
|
|
|
void
|
|
|
|
DRI2Version(int *major, int *minor)
|
|
|
|
{
|
|
|
|
if (major != NULL)
|
2012-07-10 03:03:18 +02:00
|
|
|
*major = 1;
|
2009-04-24 21:09:21 +02:00
|
|
|
|
|
|
|
if (minor != NULL)
|
2012-07-10 03:03:18 +02:00
|
|
|
*minor = 2;
|
2009-04-24 21:09:21 +02:00
|
|
|
}
|
2012-05-03 01:18:49 +02:00
|
|
|
|
|
|
|
int
|
|
|
|
DRI2GetParam(ClientPtr client,
|
|
|
|
DrawablePtr drawable,
|
|
|
|
CARD64 param,
|
|
|
|
BOOL *is_param_recognized,
|
|
|
|
CARD64 *value)
|
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(drawable->pScreen);
|
|
|
|
char high_byte = (param >> 24);
|
|
|
|
|
|
|
|
switch (high_byte) {
|
|
|
|
case 0:
|
|
|
|
/* Parameter names whose high_byte is 0 are reserved for the X
|
|
|
|
* server. The server currently recognizes no parameters.
|
|
|
|
*/
|
|
|
|
goto not_recognized;
|
|
|
|
case 1:
|
|
|
|
/* Parameter names whose high byte is 1 are reserved for the DDX. */
|
|
|
|
if (ds->GetParam)
|
|
|
|
return ds->GetParam(client, drawable, param,
|
|
|
|
is_param_recognized, value);
|
|
|
|
else
|
|
|
|
goto not_recognized;
|
|
|
|
default:
|
|
|
|
/* Other parameter names are reserved for future use. They are never
|
|
|
|
* recognized.
|
|
|
|
*/
|
|
|
|
goto not_recognized;
|
|
|
|
}
|
|
|
|
|
|
|
|
not_recognized:
|
|
|
|
*is_param_recognized = FALSE;
|
|
|
|
return Success;
|
|
|
|
}
|