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>
|
2008-02-04 17:58:24 +01:00
|
|
|
#include <xf86drm.h>
|
|
|
|
#include "xf86Module.h"
|
|
|
|
#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"
|
2009-08-28 03:39:42 +02:00
|
|
|
#include "xf86VGAarbiter.h"
|
2008-02-04 17:58:24 +01:00
|
|
|
|
|
|
|
#include "xf86.h"
|
|
|
|
|
2008-08-29 00:05:40 +02:00
|
|
|
static int dri2ScreenPrivateKeyIndex;
|
|
|
|
static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex;
|
|
|
|
static int dri2WindowPrivateKeyIndex;
|
|
|
|
static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex;
|
|
|
|
static int dri2PixmapPrivateKeyIndex;
|
|
|
|
static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
typedef struct _DRI2Drawable {
|
|
|
|
unsigned int refCount;
|
|
|
|
int width;
|
|
|
|
int height;
|
2009-07-06 20:53:02 +02:00
|
|
|
DRI2BufferPtr *buffers;
|
2008-08-11 22:59:17 +02:00
|
|
|
int bufferCount;
|
2009-07-16 15:01:17 +02:00
|
|
|
unsigned int swapsPending;
|
|
|
|
ClientPtr blockedClient;
|
|
|
|
int swap_interval;
|
|
|
|
CARD64 swap_count;
|
2010-03-04 18:54:15 +01:00
|
|
|
int64_t target_sbc; /* -1 means no SBC wait outstanding */
|
2009-07-16 15:01:17 +02:00
|
|
|
CARD64 last_swap_target; /* most recently queued swap target */
|
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
|
|
|
CARD64 last_swap_msc; /* msc at completion of most recent swap */
|
|
|
|
CARD64 last_swap_ust; /* ust at completion of most recent swap */
|
2009-07-16 15:01:17 +02:00
|
|
|
int swap_limit; /* for N-buffering */
|
2008-08-11 22:59:17 +02:00
|
|
|
} DRI2DrawableRec, *DRI2DrawablePtr;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
typedef struct _DRI2Screen *DRI2ScreenPtr;
|
|
|
|
|
2008-02-04 17:58:24 +01:00
|
|
|
typedef struct _DRI2Screen {
|
2010-01-13 20:35:52 +01:00
|
|
|
unsigned int numDrivers;
|
|
|
|
const char **driverNames;
|
2008-10-07 19:49:28 +02:00
|
|
|
const char *deviceName;
|
2008-08-11 22:59:17 +02:00
|
|
|
int fd;
|
2008-10-07 19:49:28 +02:00
|
|
|
unsigned int lastSequence;
|
2009-07-01 23:01:57 +02:00
|
|
|
|
2009-04-24 21:49:19 +02:00
|
|
|
DRI2CreateBufferProcPtr CreateBuffer;
|
|
|
|
DRI2DestroyBufferProcPtr DestroyBuffer;
|
2008-10-07 19:49:28 +02:00
|
|
|
DRI2CopyRegionProcPtr CopyRegion;
|
2009-07-16 15:01:17 +02:00
|
|
|
DRI2ScheduleSwapProcPtr ScheduleSwap;
|
|
|
|
DRI2GetMSCProcPtr GetMSC;
|
|
|
|
DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
|
2008-10-07 19:49:28 +02:00
|
|
|
|
|
|
|
HandleExposuresProcPtr HandleExposures;
|
2009-07-16 15:01:17 +02:00
|
|
|
} DRI2ScreenRec;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
|
|
|
static DRI2ScreenPtr
|
|
|
|
DRI2GetScreen(ScreenPtr pScreen)
|
|
|
|
{
|
|
|
|
return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
|
|
|
|
}
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
static DRI2DrawablePtr
|
|
|
|
DRI2GetDrawable(DrawablePtr pDraw)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2008-08-11 22:59:17 +02:00
|
|
|
WindowPtr pWin;
|
|
|
|
PixmapPtr pPixmap;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
if (!pDraw)
|
|
|
|
return NULL;
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW)
|
|
|
|
{
|
2008-02-04 17:58:24 +01:00
|
|
|
pWin = (WindowPtr) pDraw;
|
2008-08-11 22:59:17 +02:00
|
|
|
return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
2008-08-11 22:59:17 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pPixmap = (PixmapPtr) pDraw;
|
|
|
|
return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
|
2008-02-04 17:58:24 +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
|
|
|
int
|
2008-08-11 22:59:17 +02:00
|
|
|
DRI2CreateDrawable(DrawablePtr pDraw)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2010-03-04 18:19:13 +01:00
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
2008-08-11 22:59:17 +02:00
|
|
|
WindowPtr pWin;
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
DRI2DrawablePtr pPriv;
|
2010-03-04 18:19:13 +01:00
|
|
|
CARD64 ust;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv != NULL)
|
|
|
|
{
|
|
|
|
pPriv->refCount++;
|
|
|
|
return Success;
|
|
|
|
}
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
pPriv = xalloc(sizeof *pPriv);
|
|
|
|
if (pPriv == NULL)
|
|
|
|
return BadAlloc;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
pPriv->refCount = 1;
|
|
|
|
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;
|
|
|
|
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 */
|
|
|
|
if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
|
|
|
|
pPriv->last_swap_target = 0;
|
|
|
|
|
2009-07-16 15:01:17 +02: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;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW)
|
|
|
|
{
|
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
2008-08-11 22:59:17 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pPixmap = (PixmapPtr) pDraw;
|
|
|
|
dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
return Success;
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2010-01-25 18:21:51 +01:00
|
|
|
static void
|
|
|
|
DRI2FreeDrawable(DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
WindowPtr pWin;
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xfree(pPriv);
|
|
|
|
|
|
|
|
if (pDraw->type == DRAWABLE_WINDOW)
|
|
|
|
{
|
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pPixmap = (PixmapPtr) pDraw;
|
|
|
|
dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
2009-04-24 21:49:19 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-07-01 23:01:57 +02:00
|
|
|
for (i = 0; i < pPriv->bufferCount; i++) {
|
|
|
|
if ((pPriv->buffers[i] != NULL)
|
|
|
|
&& (pPriv->buffers[i]->attachment == attachment)) {
|
2009-04-24 21:49:19 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
DRI2DrawablePtr pPriv,
|
|
|
|
unsigned int attachment, unsigned int format,
|
2010-02-24 23:18:01 +01:00
|
|
|
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)
|
|
|
|
|| !dimensions_match
|
|
|
|
|| (pPriv->buffers[old_buf]->format != format)) {
|
2010-02-24 23:18:01 +01:00
|
|
|
*buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
|
|
|
|
return TRUE;
|
|
|
|
|
2009-04-24 21:49:19 +02:00
|
|
|
} else {
|
2010-02-24 23:18:01 +01:00
|
|
|
*buffer = pPriv->buffers[old_buf];
|
2009-04-24 21:49:19 +02:00
|
|
|
pPriv->buffers[old_buf] = NULL;
|
2010-02-24 23:18:01 +01:00
|
|
|
return FALSE;
|
2009-04-24 21:49:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
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
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
|
2009-07-06 20:53:02 +02: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) {
|
|
|
|
*width = pDraw->width;
|
|
|
|
*height = pDraw->height;
|
|
|
|
*out_count = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dimensions_match = (pDraw->width == pPriv->width)
|
|
|
|
&& (pDraw->height == pPriv->height);
|
2009-04-09 00:44:34 +02:00
|
|
|
|
2009-04-24 21:49:19 +02:00
|
|
|
buffers = xalloc((count + 1) * sizeof(buffers[0]));
|
2009-04-09 00:44:34 +02:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
const unsigned attachment = *(attachments++);
|
|
|
|
const unsigned format = (has_format) ? *(attachments++) : 0;
|
|
|
|
|
2010-02-24 23:18:01 +01:00
|
|
|
if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
|
|
|
|
format, dimensions_match,
|
|
|
|
&buffers[i]))
|
|
|
|
buffers_changed = 1;
|
2009-07-06 20:53:02 +02:00
|
|
|
|
|
|
|
/* 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;
|
2009-04-28 00:11:10 +02:00
|
|
|
}
|
2009-04-24 21:49:19 +02:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (attachment == DRI2BufferFrontLeft) {
|
|
|
|
need_real_front--;
|
|
|
|
front_format = format;
|
2009-04-28 00:11:10 +02:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
need_fake_front++;
|
2009-04-09 00:44:34 +02:00
|
|
|
}
|
2009-07-01 23:01:57 +02:00
|
|
|
}
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (pDraw->type == DRAWABLE_WINDOW) {
|
|
|
|
if (attachment == DRI2BufferFakeFrontLeft) {
|
2009-04-09 00:44:34 +02:00
|
|
|
need_fake_front--;
|
2009-04-09 23:38:24 +02:00
|
|
|
have_fake_front = 1;
|
2009-04-09 00:44:34 +02:00
|
|
|
}
|
2009-07-01 23:01:57 +02:00
|
|
|
}
|
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) {
|
2010-02-24 23:18:01 +01:00
|
|
|
if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
|
|
|
|
front_format, dimensions_match,
|
|
|
|
&buffers[i++]))
|
|
|
|
buffers_changed = 1;
|
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) {
|
2010-02-24 23:18:01 +01:00
|
|
|
if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
|
|
|
|
front_format, dimensions_match,
|
|
|
|
&buffers[i++]))
|
|
|
|
buffers_changed = 1;
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
have_fake_front = 1;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (pPriv->buffers != NULL) {
|
|
|
|
for (i = 0; i < pPriv->bufferCount; i++) {
|
|
|
|
if (pPriv->buffers[i] != NULL) {
|
|
|
|
(*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
|
|
|
|
}
|
2009-07-01 23:01:57 +02:00
|
|
|
}
|
2009-07-06 20:53:02 +02:00
|
|
|
|
|
|
|
xfree(pPriv->buffers);
|
2009-04-09 00:44:34 +02:00
|
|
|
}
|
|
|
|
|
2009-04-24 21:49:19 +02:00
|
|
|
pPriv->buffers = buffers;
|
|
|
|
pPriv->bufferCount = *out_count;
|
2009-05-11 22:52:46 +02:00
|
|
|
pPriv->width = pDraw->width;
|
|
|
|
pPriv->height = pDraw->height;
|
2008-08-11 22:59:17 +02:00
|
|
|
*width = pPriv->width;
|
|
|
|
*height = pPriv->height;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
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) {
|
2009-04-09 23:38:24 +02:00
|
|
|
BoxRec box;
|
|
|
|
RegionRec region;
|
|
|
|
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pPriv->width;
|
|
|
|
box.y2 = pPriv->height;
|
|
|
|
REGION_INIT(pDraw->pScreen, ®ion, &box, 0);
|
|
|
|
|
|
|
|
DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft,
|
|
|
|
DRI2BufferFrontLeft);
|
|
|
|
}
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
return pPriv->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,
|
|
|
|
unsigned int *attachments, int count, int *out_count)
|
|
|
|
{
|
|
|
|
return do_get_buffers(pDraw, width, height, attachments, count,
|
|
|
|
out_count, FALSE);
|
|
|
|
}
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
DRI2BufferPtr *
|
2009-04-24 21:49:19 +02:00
|
|
|
DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
|
|
|
|
unsigned int *attachments, int count, int *out_count)
|
|
|
|
{
|
|
|
|
return do_get_buffers(pDraw, width, height, attachments, count,
|
|
|
|
out_count, TRUE);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Throttle to swap limit */
|
|
|
|
if ((pPriv->swapsPending >= pPriv->swap_limit) &&
|
|
|
|
!pPriv->blockedClient) {
|
|
|
|
ResetCurrentRequest(client);
|
|
|
|
client->sequence--;
|
|
|
|
IgnoreClient(client);
|
|
|
|
pPriv->blockedClient = client;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pPriv->blockedClient == NULL) {
|
|
|
|
IgnoreClient(client);
|
|
|
|
pPriv->blockedClient = client;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
unsigned int dest, unsigned int src)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2008-08-11 22:59:17 +02:00
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv;
|
2008-10-07 19:49:28 +02:00
|
|
|
DRI2BufferPtr pDestBuffer, pSrcBuffer;
|
2008-08-11 22:59:17 +02:00
|
|
|
int i;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
2008-10-07 19:49:28 +02: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;
|
|
|
|
for (i = 0; i < pPriv->bufferCount; i++)
|
|
|
|
{
|
2009-04-24 21:49:19 +02:00
|
|
|
if (pPriv->buffers[i]->attachment == dest)
|
2009-07-01 23:01:57 +02:00
|
|
|
pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
|
2009-04-24 21:49:19 +02:00
|
|
|
if (pPriv->buffers[i]->attachment == src)
|
2009-07-01 23:01:57 +02:00
|
|
|
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)
|
|
|
|
return BadValue;
|
2009-07-01 23:01:57 +02:00
|
|
|
|
2008-10-07 19:49:28 +02:00
|
|
|
(*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
|
|
|
|
|
|
|
|
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)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
pRoot = WindowTable[pScreen->myNum];
|
|
|
|
pRootPixmap = pScreen->GetWindowPixmap(pRoot);
|
|
|
|
|
|
|
|
pWin = (WindowPtr) pDraw;
|
|
|
|
pWinPixmap = pScreen->GetWindowPixmap(pWin);
|
|
|
|
if (pRootPixmap != pWinPixmap)
|
|
|
|
return FALSE;
|
|
|
|
if (!REGION_EQUAL(pScreen, &pWin->clipList, &pRoot->winSize))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
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,
|
|
|
|
unsigned int tv_sec, unsigned int tv_usec)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
|
|
|
|
frame, pPriv->swap_count);
|
|
|
|
|
|
|
|
if (pPriv->blockedClient)
|
|
|
|
AttendClient(pPriv->blockedClient);
|
|
|
|
|
|
|
|
pPriv->blockedClient = NULL;
|
2010-03-05 18:15:24 +01:00
|
|
|
|
|
|
|
/* If there's still a swap pending, let DRI2SwapComplete free it */
|
|
|
|
if (pPriv->refCount == 0 && pPriv->swapsPending == 0)
|
|
|
|
DRI2FreeDrawable(pDraw);
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
|
|
|
|
unsigned int tv_sec, unsigned int tv_usec)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Swap completed. Either wake up an SBC waiter or a client that was
|
|
|
|
* blocked due to GLX activity during a swap.
|
|
|
|
*/
|
|
|
|
if (pPriv->target_sbc != -1 &&
|
2010-02-21 05:25:59 +01:00
|
|
|
pPriv->target_sbc <= pPriv->swap_count) {
|
2009-07-16 15:01:17 +02:00
|
|
|
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) {
|
|
|
|
if (pPriv->blockedClient)
|
|
|
|
AttendClient(pPriv->blockedClient);
|
|
|
|
pPriv->blockedClient = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
|
|
|
|
unsigned int tv_sec, unsigned int tv_usec, int type,
|
|
|
|
DRI2SwapEventPtr swap_complete, void *swap_data)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
CARD64 ust = 0;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-02-21 05:25:59 +01:00
|
|
|
pPriv->swapsPending--;
|
|
|
|
pPriv->swap_count++;
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
ust = ((CARD64)tv_sec * 1000000) + tv_usec;
|
|
|
|
if (swap_complete)
|
|
|
|
swap_complete(client, swap_data, type, ust, frame, 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
|
|
|
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);
|
2010-03-05 18:15:24 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* It's normal for the app to have exited with a swap outstanding, but
|
|
|
|
* don't free the drawable until they're all complete.
|
|
|
|
*/
|
|
|
|
if (pPriv->swapsPending == 0 && pPriv->refCount == 0)
|
|
|
|
DRI2FreeDrawable(pDraw);
|
2009-07-16 15:01:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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. */
|
|
|
|
if ((pPriv->swapsPending) &&
|
|
|
|
pPriv->blockedClient == NULL) {
|
|
|
|
ResetCurrentRequest(client);
|
|
|
|
client->sequence--;
|
|
|
|
DRI2BlockClient(client, pDrawable);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
|
|
|
|
CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
|
|
|
|
DRI2SwapEventPtr func, void *data)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
|
|
|
|
int ret, i;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return BadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < pPriv->bufferCount; i++) {
|
|
|
|
if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
|
|
|
|
pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
|
|
|
|
if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
|
|
|
|
pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
|
|
|
|
}
|
|
|
|
if (pSrcBuffer == NULL || pDestBuffer == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
|
|
|
"[DRI2] %s: drawable has no back or front?\n", __func__);
|
|
|
|
return BadDrawable;
|
|
|
|
}
|
|
|
|
|
2010-03-05 18:49:03 +01:00
|
|
|
/* Old DDX or no swap interval, just blit */
|
|
|
|
if (!ds->ScheduleSwap || !pPriv->swap_interval) {
|
2009-07-16 15:01:17 +02:00
|
|
|
BoxRec box;
|
|
|
|
RegionRec region;
|
|
|
|
|
|
|
|
box.x1 = 0;
|
|
|
|
box.y1 = 0;
|
|
|
|
box.x2 = pDraw->width;
|
|
|
|
box.y2 = pDraw->height;
|
|
|
|
REGION_INIT(pScreen, ®ion, &box, 0);
|
|
|
|
|
|
|
|
pPriv->swapsPending++;
|
|
|
|
|
|
|
|
(*ds->CopyRegion)(pDraw, ®ion, pDestBuffer, pSrcBuffer);
|
|
|
|
DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
|
|
|
|
func, data);
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
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) {
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
*swap_target = pPriv->last_swap_target + pPriv->swap_interval;
|
|
|
|
} else {
|
|
|
|
/* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
|
|
|
|
*swap_target = target_msc;
|
|
|
|
}
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
|
|
|
|
swap_target, divisor, remainder, func, data);
|
|
|
|
if (!ret) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
|
|
|
"[DRI2] %s: driver failed to schedule swap\n", __func__);
|
|
|
|
return BadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
pPriv->swapsPending++;
|
|
|
|
pPriv->last_swap_target = *swap_target;
|
|
|
|
|
2010-03-04 19:31:59 +01:00
|
|
|
/* According to spec, return expected swapbuffers count SBC after this swap
|
|
|
|
* will complete.
|
|
|
|
*/
|
|
|
|
*swap_target = pPriv->swap_count + pPriv->swapsPending;
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DRI2SwapInterval(DrawablePtr pDrawable, int interval)
|
|
|
|
{
|
2010-03-05 18:15:24 +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,
|
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
|
DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
|
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pDraw->pScreen;
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
|
|
|
if (pPriv == NULL) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
|
|
|
"[DRI2] %s: bad drawable\n", __func__);
|
|
|
|
return BadDrawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ds->GetMSC) {
|
|
|
|
*ust = 0;
|
|
|
|
*msc = 0;
|
|
|
|
*sbc = pPriv->swap_count;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Spec needs to be updated to include unmapped or redirected
|
|
|
|
* drawables
|
|
|
|
*/
|
|
|
|
|
|
|
|
ret = (*ds->GetMSC)(pDraw, ust, msc);
|
|
|
|
if (!ret)
|
|
|
|
return BadDrawable;
|
|
|
|
|
|
|
|
*sbc = pPriv->swap_count;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
|
|
|
|
CARD64 divisor, CARD64 remainder)
|
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
Bool ret;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
2010-03-05 18:15:24 +01:00
|
|
|
if (pPriv == NULL || pPriv->refCount == 0)
|
2009-07-16 15:01:17 +02:00
|
|
|
return BadDrawable;
|
|
|
|
|
|
|
|
/* Old DDX just completes immediately */
|
|
|
|
if (!ds->ScheduleWaitMSC) {
|
|
|
|
DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
|
|
|
|
if (!ret)
|
|
|
|
return BadDrawable;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
|
|
|
|
CARD64 *ust, CARD64 *msc, CARD64 *sbc)
|
|
|
|
{
|
|
|
|
DRI2DrawablePtr pPriv;
|
|
|
|
|
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
2010-03-05 18:15:24 +01:00
|
|
|
if (pPriv == NULL || pPriv->refCount == 0)
|
2009-07-16 15:01:17 +02:00
|
|
|
return BadDrawable;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* If current swap count already >= target_sbc,
|
|
|
|
* return immediately with (ust, msc, sbc) triplet of
|
|
|
|
* most recent completed swap.
|
|
|
|
*/
|
|
|
|
if (pPriv->swap_count >= target_sbc) {
|
|
|
|
*sbc = pPriv->swap_count;
|
|
|
|
*msc = pPriv->last_swap_msc;
|
|
|
|
*ust = pPriv->last_swap_ust;
|
|
|
|
return Success;
|
|
|
|
}
|
2009-07-16 15:01:17 +02:00
|
|
|
|
|
|
|
pPriv->target_sbc = target_sbc;
|
|
|
|
DRI2BlockClient(client, pDraw);
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
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-03-27 00:28:09 +01:00
|
|
|
DRI2DestroyDrawable(DrawablePtr pDraw)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
2008-08-11 22:59:17 +02:00
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
|
|
|
|
DRI2DrawablePtr pPriv;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
pPriv = DRI2GetDrawable(pDraw);
|
2008-02-04 17:58:24 +01:00
|
|
|
if (pPriv == NULL)
|
|
|
|
return;
|
2009-07-01 23:01:57 +02:00
|
|
|
|
2008-03-27 00:28:09 +01:00
|
|
|
pPriv->refCount--;
|
2008-08-11 22:59:17 +02:00
|
|
|
if (pPriv->refCount > 0)
|
|
|
|
return;
|
2008-03-27 00:28:09 +01:00
|
|
|
|
2009-04-24 21:49:19 +02:00
|
|
|
if (pPriv->buffers != NULL) {
|
|
|
|
int i;
|
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
for (i = 0; i < pPriv->bufferCount; i++)
|
|
|
|
(*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
|
2009-04-24 21:49:19 +02:00
|
|
|
|
|
|
|
xfree(pPriv->buffers);
|
|
|
|
}
|
|
|
|
|
2010-03-05 18:15:24 +01:00
|
|
|
/* If the window is destroyed while we have a swap or wait pending, don't
|
2009-07-16 15:01:17 +02:00
|
|
|
* actually free the priv yet. We'll need it in the DRI2SwapComplete()
|
|
|
|
* callback and we'll free it there once we're done. */
|
2010-03-05 18:15:24 +01:00
|
|
|
if (!pPriv->swapsPending && !pPriv->blockedClient)
|
2010-01-25 18:21:51 +01:00
|
|
|
DRI2FreeDrawable(pDraw);
|
2008-02-04 17:58:24 +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
|
2008-10-07 19:49:28 +02:00
|
|
|
DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
|
|
|
|
const char **driverName, const char **deviceName)
|
2008-02-04 17:58:24 +01:00
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
|
|
|
|
|
2010-01-13 20:35:52 +01:00
|
|
|
if (ds == NULL || driverType >= ds->numDrivers ||
|
|
|
|
!ds->driverNames[driverType])
|
2008-02-04 17:58:24 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*fd = ds->fd;
|
2010-01-13 20:35:52 +01:00
|
|
|
*driverName = ds->driverNames[driverType];
|
2008-10-07 19:49:28 +02:00
|
|
|
*deviceName = ds->deviceName;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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-10-07 19:49:28 +02:00
|
|
|
DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
|
2008-03-11 05:35:31 +01:00
|
|
|
{
|
|
|
|
DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
|
|
|
|
|
|
|
|
if (ds == NULL || drmAuthMagic(ds->fd, magic))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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;
|
2010-01-13 20:35:52 +01:00
|
|
|
const char* driverTypeNames[] = {
|
|
|
|
"DRI", /* DRI2DriverDRI */
|
|
|
|
"VDPAU", /* DRI2DriverVDPAU */
|
|
|
|
};
|
|
|
|
unsigned int i;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
if (info->version < 3)
|
|
|
|
return FALSE;
|
|
|
|
|
2009-08-28 03:39:42 +02:00
|
|
|
if (!xf86VGAarbiterAllowDRI(pScreen)) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_WARNING,
|
|
|
|
"[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
ds = xcalloc(1, sizeof *ds);
|
2008-02-04 17:58:24 +01:00
|
|
|
if (!ds)
|
2008-08-11 22:59:17 +02:00
|
|
|
return FALSE;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
ds->fd = info->fd;
|
2008-10-07 19:49:28 +02:00
|
|
|
ds->deviceName = info->deviceName;
|
2009-07-01 23:01:57 +02:00
|
|
|
|
2009-07-06 20:53:02 +02:00
|
|
|
ds->CreateBuffer = info->CreateBuffer;
|
|
|
|
ds->DestroyBuffer = info->DestroyBuffer;
|
2008-10-07 19:49:28 +02:00
|
|
|
ds->CopyRegion = info->CopyRegion;
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2009-07-16 15:01:17 +02:00
|
|
|
if (info->version >= 4) {
|
|
|
|
ds->ScheduleSwap = info->ScheduleSwap;
|
|
|
|
ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
|
|
|
|
ds->GetMSC = info->GetMSC;
|
|
|
|
}
|
|
|
|
|
2010-01-13 20:35:52 +01:00
|
|
|
if (info->version == 3 || info->numDrivers == 0) {
|
|
|
|
/* Driver too old: use the old-style driverName field */
|
|
|
|
ds->numDrivers = 1;
|
|
|
|
ds->driverNames = xalloc(sizeof(*ds->driverNames));
|
|
|
|
if (!ds->driverNames) {
|
|
|
|
xfree(ds);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ds->driverNames[0] = info->driverName;
|
|
|
|
} else {
|
|
|
|
ds->numDrivers = info->numDrivers;
|
|
|
|
ds->driverNames = xalloc(info->numDrivers * sizeof(*ds->driverNames));
|
|
|
|
if (!ds->driverNames) {
|
|
|
|
xfree(ds);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
memcpy(ds->driverNames, info->driverNames,
|
|
|
|
info->numDrivers * sizeof(*ds->driverNames));
|
|
|
|
}
|
|
|
|
|
2008-02-04 17:58:24 +01:00
|
|
|
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
|
|
|
|
|
|
|
|
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++) {
|
|
|
|
if (i < ds->numDrivers && ds->driverNames[i]) {
|
|
|
|
xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
|
|
|
|
driverTypeNames[i], ds->driverNames[i]);
|
|
|
|
}
|
|
|
|
}
|
2008-02-04 17:58:24 +01:00
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2010-01-13 20:35:52 +01:00
|
|
|
xfree(ds->driverNames);
|
2008-08-11 22:59:17 +02:00
|
|
|
xfree(ds);
|
|
|
|
dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
|
2008-02-04 17:58:24 +01:00
|
|
|
}
|
|
|
|
|
2008-03-27 00:28:09 +01:00
|
|
|
extern ExtensionModule dri2ExtensionModule;
|
|
|
|
|
2008-02-04 17:58:24 +01:00
|
|
|
static pointer
|
|
|
|
DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
|
|
|
|
{
|
2008-03-27 00:28:09 +01:00
|
|
|
static Bool setupDone = FALSE;
|
|
|
|
|
2008-08-11 22:59:17 +02:00
|
|
|
if (!setupDone)
|
|
|
|
{
|
2008-03-27 00:28:09 +01:00
|
|
|
setupDone = TRUE;
|
|
|
|
LoadExtension(&dri2ExtensionModule, FALSE);
|
2008-08-11 22:59:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-27 00:28:09 +01:00
|
|
|
if (errmaj)
|
|
|
|
*errmaj = LDR_ONCEONLY;
|
|
|
|
}
|
|
|
|
|
2008-02-04 17:58:24 +01:00
|
|
|
return (pointer) 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static XF86ModuleVersionInfo DRI2VersRec =
|
|
|
|
{
|
|
|
|
"dri2",
|
|
|
|
MODULEVENDORSTRING,
|
|
|
|
MODINFOSTRING1,
|
|
|
|
MODINFOSTRING2,
|
|
|
|
XORG_VERSION_CURRENT,
|
2010-01-28 23:33:25 +01:00
|
|
|
1, 2, 0,
|
2008-02-04 17:58:24 +01:00
|
|
|
ABI_CLASS_EXTENSION,
|
|
|
|
ABI_EXTENSION_VERSION,
|
|
|
|
MOD_CLASS_NONE,
|
|
|
|
{ 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
|
|
|
|
|
2009-04-24 21:09:21 +02:00
|
|
|
void
|
|
|
|
DRI2Version(int *major, int *minor)
|
|
|
|
{
|
|
|
|
if (major != NULL)
|
|
|
|
*major = DRI2VersRec.majorversion;
|
|
|
|
|
|
|
|
if (minor != NULL)
|
|
|
|
*minor = DRI2VersRec.minorversion;
|
|
|
|
}
|