2005-07-01 10:56:12 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright <EFBFBD> 2001 Keith Packard
|
|
|
|
|
*
|
|
|
|
|
* Partly based on code that is Copyright <EFBFBD> The XFree86 Project Inc.
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
|
* documentation, and that the name of Keith Packard not be used in
|
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
|
* specific, written prior permission. Keith Packard makes no
|
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
|
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/** @file
|
|
|
|
|
* This file covers the initialization and teardown of EXA, and has various
|
|
|
|
|
* functions not responsible for performing rendering, pixmap migration, or
|
|
|
|
|
* memory management.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-02-16 01:14:11 +01:00
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
|
#include <dix-config.h>
|
2005-07-01 10:56:12 +02:00
|
|
|
|
#endif
|
2006-02-16 01:14:11 +01:00
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2006-02-02 21:09:14 +01:00
|
|
|
|
#include "exa_priv.h"
|
2005-07-03 09:02:09 +02:00
|
|
|
|
#include <X11/fonts/fontstruct.h>
|
2005-07-01 10:56:12 +02:00
|
|
|
|
#include "dixfontstr.h"
|
|
|
|
|
#include "exa.h"
|
2005-10-02 10:28:27 +02:00
|
|
|
|
#include "cw.h"
|
2005-07-01 10:56:12 +02:00
|
|
|
|
|
2005-09-30 04:03:45 +02:00
|
|
|
|
static int exaGeneration;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
int exaScreenPrivateIndex;
|
|
|
|
|
int exaPixmapPrivateIndex;
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaGetPixmapOffset() returns the offset (in bytes) within the framebuffer of
|
|
|
|
|
* the beginning of the given pixmap.
|
|
|
|
|
*
|
|
|
|
|
* Note that drivers are free to, and often do, munge this offset as necessary
|
|
|
|
|
* for handing to the hardware -- for example, translating it into a different
|
|
|
|
|
* aperture. This function may need to be extended in the future if we grow
|
|
|
|
|
* support for having multiple card-accessible offscreen, such as an AGP memory
|
|
|
|
|
* pool alongside the framebuffer pool.
|
2005-08-25 00:43:27 +02:00
|
|
|
|
*/
|
|
|
|
|
unsigned long
|
|
|
|
|
exaGetPixmapOffset(PixmapPtr pPix)
|
|
|
|
|
{
|
|
|
|
|
ExaScreenPriv (pPix->drawable.pScreen);
|
|
|
|
|
|
|
|
|
|
return ((unsigned long)pPix->devPrivate.ptr -
|
2006-03-09 07:04:07 +01:00
|
|
|
|
(unsigned long)pExaScr->info->memoryBase);
|
2005-08-25 00:43:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaGetPixmapPitch() returns the pitch (in bytes) of the given pixmap.
|
|
|
|
|
*
|
|
|
|
|
* This is a helper to make driver code more obvious, due to the rather obscure
|
|
|
|
|
* naming of the pitch field in the pixmap.
|
|
|
|
|
*/
|
2005-08-25 00:43:27 +02:00
|
|
|
|
unsigned long
|
|
|
|
|
exaGetPixmapPitch(PixmapPtr pPix)
|
|
|
|
|
{
|
|
|
|
|
return pPix->devKind;
|
|
|
|
|
}
|
2005-07-01 10:56:12 +02:00
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaGetPixmapSize() returns the size in bytes of the given pixmap in video
|
|
|
|
|
* memory. Only valid when the pixmap is currently in framebuffer.
|
2005-09-11 21:08:10 +02:00
|
|
|
|
*/
|
|
|
|
|
unsigned long
|
|
|
|
|
exaGetPixmapSize(PixmapPtr pPix)
|
|
|
|
|
{
|
|
|
|
|
ExaPixmapPrivPtr pExaPixmap;
|
|
|
|
|
|
|
|
|
|
pExaPixmap = ExaGetPixmapPriv(pPix);
|
|
|
|
|
if (pExaPixmap != NULL)
|
|
|
|
|
return pExaPixmap->size;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaGetDrawablePixmap() returns a backing pixmap for a given drawable.
|
|
|
|
|
*
|
|
|
|
|
* @param pDrawable the drawable being requested.
|
|
|
|
|
*
|
|
|
|
|
* This function returns the backing pixmap for a drawable, whether it is a
|
|
|
|
|
* redirected window, unredirected window, or already a pixmap. Note that
|
|
|
|
|
* coordinate translation is needed when drawing to the backing pixmap of a
|
|
|
|
|
* redirected window, and the translation coordinates are provided by calling
|
|
|
|
|
* exaGetOffscreenPixmap() on the drawable.
|
|
|
|
|
*/
|
2006-02-02 22:07:06 +01:00
|
|
|
|
PixmapPtr
|
|
|
|
|
exaGetDrawablePixmap(DrawablePtr pDrawable)
|
|
|
|
|
{
|
|
|
|
|
if (pDrawable->type == DRAWABLE_WINDOW)
|
|
|
|
|
return pDrawable->pScreen->GetWindowPixmap ((WindowPtr) pDrawable);
|
|
|
|
|
else
|
|
|
|
|
return (PixmapPtr) pDrawable;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaDrawableDirty() marks a pixmap backing a drawable as dirty, allowing for
|
|
|
|
|
* optimizations in pixmap migration when no changes have occurred.
|
|
|
|
|
*/
|
2005-07-01 10:56:12 +02:00
|
|
|
|
void
|
|
|
|
|
exaDrawableDirty (DrawablePtr pDrawable)
|
|
|
|
|
{
|
|
|
|
|
ExaPixmapPrivPtr pExaPixmap;
|
|
|
|
|
|
2006-02-02 22:07:06 +01:00
|
|
|
|
pExaPixmap = ExaGetPixmapPriv(exaGetDrawablePixmap (pDrawable));
|
2005-07-01 10:56:12 +02:00
|
|
|
|
if (pExaPixmap != NULL)
|
|
|
|
|
pExaPixmap->dirty = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
exaDestroyPixmap (PixmapPtr pPixmap)
|
|
|
|
|
{
|
|
|
|
|
if (pPixmap->refcnt == 1)
|
|
|
|
|
{
|
|
|
|
|
ExaPixmapPriv (pPixmap);
|
|
|
|
|
if (pExaPixmap->area)
|
|
|
|
|
{
|
|
|
|
|
DBG_PIXMAP(("-- 0x%p (0x%x) (%dx%d)\n",
|
|
|
|
|
(void*)pPixmap->drawable.id,
|
|
|
|
|
ExaGetPixmapPriv(pPixmap)->area->offset,
|
|
|
|
|
pPixmap->drawable.width,
|
|
|
|
|
pPixmap->drawable.height));
|
|
|
|
|
/* Free the offscreen area */
|
|
|
|
|
exaOffscreenFree (pPixmap->drawable.pScreen, pExaPixmap->area);
|
|
|
|
|
pPixmap->devPrivate = pExaPixmap->devPrivate;
|
|
|
|
|
pPixmap->devKind = pExaPixmap->devKind;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fbDestroyPixmap (pPixmap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PixmapPtr
|
|
|
|
|
exaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
ExaPixmapPrivPtr pExaPixmap;
|
|
|
|
|
int bpp;
|
2005-07-09 16:15:35 +02:00
|
|
|
|
ExaScreenPriv(pScreen);
|
2005-07-07 17:05:02 +02:00
|
|
|
|
|
2005-09-13 03:33:19 +02:00
|
|
|
|
if (w > 32767 || h > 32767)
|
|
|
|
|
return NullPixmap;
|
2005-10-20 23:45:40 +02:00
|
|
|
|
|
2006-02-16 01:14:11 +01:00
|
|
|
|
pPixmap = fbCreatePixmap (pScreen, w, h, depth);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
if (!pPixmap)
|
|
|
|
|
return NULL;
|
|
|
|
|
pExaPixmap = ExaGetPixmapPriv(pPixmap);
|
- Don't try to upload 0 byte-per-pixel (PICT_a1) data using
RADEONHostDataBlit.
- Disable the shortcut for switching from 3d to 3d in radeon_exa.c. It
appears that we do need the cache flush here, thought it's not clear
why. Disable the 2d to 2d shortcut while here, since I'm unsure of what
we're doing. Exposed by the following bit:
- Bug #4485: Add a new routine, exaGlyphs, to handle font drawing. Glyphs
were being accumulated in from non-migratable scratch pixmaps, causing
the destination pixmap to move towards screen but the migration
necessary for source never to happen, leading to abysmal performance.
Instead, copy the scratch glyph data into a real pixmap first, then
composite from that into the destination, allowing for migration. time
ls -lR from programs/Xserver showed 26.9% (+/- 6.3%) decrease in wall
time (n=3).
- Create exaDrawableUse* wrapping exaPixmapUse*, but which are aware of
windows needing backing store. Makes migration code prettier, and
ensures that composited windows will be migrated as normal when we turn
off cw for EXA. (issue brought up by keithp)
2005-09-17 22:02:02 +02:00
|
|
|
|
|
|
|
|
|
/* Glyphs have w/h equal to zero, and may not be migrated. See exaGlyphs. */
|
2005-07-01 10:56:12 +02:00
|
|
|
|
if (!w || !h)
|
|
|
|
|
pExaPixmap->score = EXA_PIXMAP_SCORE_PINNED;
|
|
|
|
|
else
|
|
|
|
|
pExaPixmap->score = EXA_PIXMAP_SCORE_INIT;
|
|
|
|
|
|
|
|
|
|
pExaPixmap->area = NULL;
|
|
|
|
|
pExaPixmap->dirty = FALSE;
|
|
|
|
|
|
|
|
|
|
return pPixmap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
exaPixmapIsOffscreen(PixmapPtr p)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = p->drawable.pScreen;
|
|
|
|
|
ExaScreenPriv(pScreen);
|
|
|
|
|
|
|
|
|
|
return ((unsigned long) ((CARD8 *) p->devPrivate.ptr -
|
2006-03-09 07:04:07 +01:00
|
|
|
|
(CARD8 *) pExaScr->info->memoryBase) <
|
|
|
|
|
pExaScr->info->memorySize);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-02-02 22:07:06 +01:00
|
|
|
|
Bool
|
|
|
|
|
exaDrawableIsOffscreen (DrawablePtr pDrawable)
|
|
|
|
|
{
|
|
|
|
|
return exaPixmapIsOffscreen (exaGetDrawablePixmap (pDrawable));
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-01 10:56:12 +02:00
|
|
|
|
PixmapPtr
|
|
|
|
|
exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
|
|
|
|
|
{
|
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
|
|
if (pDrawable->type == DRAWABLE_WINDOW) {
|
|
|
|
|
pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
|
|
|
|
|
#ifdef COMPOSITE
|
|
|
|
|
x = -pPixmap->screen_x;
|
|
|
|
|
y = -pPixmap->screen_y;
|
|
|
|
|
#else
|
|
|
|
|
x = 0;
|
|
|
|
|
y = 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPixmap = (PixmapPtr) pDrawable;
|
|
|
|
|
x = 0;
|
|
|
|
|
y = 0;
|
|
|
|
|
}
|
|
|
|
|
*xp = x;
|
|
|
|
|
*yp = y;
|
|
|
|
|
if (exaPixmapIsOffscreen (pPixmap))
|
|
|
|
|
return pPixmap;
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-11 21:08:10 +02:00
|
|
|
|
void
|
|
|
|
|
exaPrepareAccess(DrawablePtr pDrawable, int index)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = pDrawable->pScreen;
|
|
|
|
|
ExaScreenPriv (pScreen);
|
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
|
2006-02-02 22:07:06 +01:00
|
|
|
|
pPixmap = exaGetDrawablePixmap (pDrawable);
|
2005-09-11 21:08:10 +02:00
|
|
|
|
|
|
|
|
|
if (index == EXA_PREPARE_DEST)
|
|
|
|
|
exaDrawableDirty (pDrawable);
|
|
|
|
|
if (exaPixmapIsOffscreen (pPixmap))
|
|
|
|
|
exaWaitSync (pDrawable->pScreen);
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
if (pExaScr->info->PrepareAccess == NULL)
|
2005-09-11 21:08:10 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
if (!(*pExaScr->info->PrepareAccess) (pPixmap, index)) {
|
2005-09-11 21:08:10 +02:00
|
|
|
|
ExaPixmapPriv (pPixmap);
|
- Change migration-in rule slightly: previously, if your score was less
than the max, it was bumped, and then if you were above the threshhold
you got moved in. Instead, do the above-threshhold check separate from
score starting out less than max. While this will likely make thrashing
cases worse, I hope it will fix some issues with long term performance
(think of an xcompmgr with a backbuffer it's doing only accelerated
operations to. If some new pixmap comes in and bumps it out, even once,
it will never get a chance to re-migrate because its score will be
maxed). Change migration-out to be the same way for symmetry, though it
shouldn't ever affect anything.
- Fix a lot of debugging output, both in terms of printing quality, and
completeness. The fallback debugging covers a lot more now, pointing
out new areas for improvement. Debugging toggles are now centralized in
exaPriv.h.
2005-09-21 12:27:53 +02:00
|
|
|
|
if (pExaPixmap->score != EXA_PIXMAP_SCORE_PINNED)
|
|
|
|
|
FatalError("Driver failed PrepareAccess on a pinned pixmap\n");
|
2005-09-11 21:08:10 +02:00
|
|
|
|
exaMoveOutPixmap (pPixmap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
exaFinishAccess(DrawablePtr pDrawable, int index)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = pDrawable->pScreen;
|
|
|
|
|
ExaScreenPriv (pScreen);
|
|
|
|
|
PixmapPtr pPixmap;
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
if (pExaScr->info->FinishAccess == NULL)
|
2005-09-11 21:08:10 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2006-02-02 22:07:06 +01:00
|
|
|
|
pPixmap = exaGetDrawablePixmap (pDrawable);
|
2005-09-11 21:08:10 +02:00
|
|
|
|
if (!exaPixmapIsOffscreen (pPixmap))
|
|
|
|
|
return;
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
(*pExaScr->info->FinishAccess) (pPixmap, index);
|
2005-09-11 21:08:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-01 10:56:12 +02:00
|
|
|
|
static void
|
|
|
|
|
exaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
|
|
|
|
|
{
|
|
|
|
|
fbValidateGC (pGC, changes, pDrawable);
|
|
|
|
|
|
|
|
|
|
if (exaDrawableIsOffscreen (pDrawable))
|
|
|
|
|
pGC->ops = (GCOps *) &exaOps;
|
|
|
|
|
else
|
|
|
|
|
pGC->ops = (GCOps *) &exaAsyncPixmapGCOps;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-30 04:03:45 +02:00
|
|
|
|
static GCFuncs exaGCFuncs = {
|
2005-07-01 10:56:12 +02:00
|
|
|
|
exaValidateGC,
|
|
|
|
|
miChangeGC,
|
|
|
|
|
miCopyGC,
|
|
|
|
|
miDestroyGC,
|
|
|
|
|
miChangeClip,
|
|
|
|
|
miDestroyClip,
|
|
|
|
|
miCopyClip
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
exaCreateGC (GCPtr pGC)
|
|
|
|
|
{
|
|
|
|
|
if (!fbCreateGC (pGC))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
pGC->funcs = &exaGCFuncs;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-04 16:15:57 +02:00
|
|
|
|
static Bool
|
|
|
|
|
exaCloseScreen(int i, ScreenPtr pScreen)
|
|
|
|
|
{
|
|
|
|
|
ExaScreenPriv(pScreen);
|
|
|
|
|
#ifdef RENDER
|
|
|
|
|
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
pScreen->CreateGC = pExaScr->SavedCreateGC;
|
|
|
|
|
pScreen->CloseScreen = pExaScr->SavedCloseScreen;
|
|
|
|
|
pScreen->GetImage = pExaScr->SavedGetImage;
|
|
|
|
|
pScreen->GetSpans = pExaScr->SavedGetSpans;
|
|
|
|
|
pScreen->PaintWindowBackground = pExaScr->SavedPaintWindowBackground;
|
|
|
|
|
pScreen->PaintWindowBorder = pExaScr->SavedPaintWindowBorder;
|
|
|
|
|
pScreen->CreatePixmap = pExaScr->SavedCreatePixmap;
|
|
|
|
|
pScreen->DestroyPixmap = pExaScr->SavedDestroyPixmap;
|
|
|
|
|
pScreen->CopyWindow = pExaScr->SavedCopyWindow;
|
|
|
|
|
#ifdef RENDER
|
|
|
|
|
if (ps) {
|
|
|
|
|
ps->Composite = pExaScr->SavedComposite;
|
2005-09-28 22:01:37 +02:00
|
|
|
|
ps->Glyphs = pExaScr->SavedGlyphs;
|
2005-07-04 16:15:57 +02:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
xfree (pExaScr);
|
|
|
|
|
|
|
|
|
|
return (*pScreen->CloseScreen) (i, pScreen);
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
/**
|
|
|
|
|
* This function allocates a driver structure for EXA drivers to fill in. By
|
|
|
|
|
* having EXA allocate the structure, the driver structure can be extended
|
|
|
|
|
* without breaking ABI between EXA and the drivers. The driver's
|
|
|
|
|
* responsibility is to check beforehand that the EXA module has a matching
|
|
|
|
|
* major number and sufficient minor. Drivers are responsible for freeing the
|
|
|
|
|
* driver structure using xfree().
|
2006-03-10 00:18:15 +01:00
|
|
|
|
*
|
|
|
|
|
* @return a newly allocated, zero-filled driver structure
|
2006-03-09 07:04:07 +01:00
|
|
|
|
*/
|
|
|
|
|
ExaDriverPtr
|
|
|
|
|
exaDriverAlloc(void)
|
|
|
|
|
{
|
|
|
|
|
return xcalloc(1, sizeof(ExaDriverRec));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2006-03-10 00:18:15 +01:00
|
|
|
|
* @param pScreen screen being initialized
|
|
|
|
|
* @param pScreenInfo EXA driver record
|
|
|
|
|
*
|
2006-03-09 07:04:07 +01:00
|
|
|
|
* exaDriverInit sets up EXA given a driver record filled in by the driver.
|
2006-03-10 00:18:15 +01:00
|
|
|
|
* pScreenInfo should have been allocated by exaDriverAlloc(). See the
|
|
|
|
|
* comments in _ExaDriver for what must be filled in and what is optional.
|
|
|
|
|
*
|
|
|
|
|
* @return TRUE if EXA was successfully initialized.
|
2006-03-09 07:04:07 +01:00
|
|
|
|
*/
|
2005-07-01 10:56:12 +02:00
|
|
|
|
Bool
|
|
|
|
|
exaDriverInit (ScreenPtr pScreen,
|
|
|
|
|
ExaDriverPtr pScreenInfo)
|
|
|
|
|
{
|
|
|
|
|
ExaScreenPrivPtr pExaScr;
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
if (pScreenInfo->exa_major != EXA_VERSION_MAJOR ||
|
|
|
|
|
pScreenInfo->exa_minor > EXA_VERSION_MINOR)
|
|
|
|
|
{
|
|
|
|
|
LogMessage(X_ERROR, "EXA(%d): driver's EXA version requirements "
|
|
|
|
|
"(%d.%d) are incompatible with EXA version (%d.%d)\n",
|
|
|
|
|
pScreen->myNum,
|
|
|
|
|
pScreenInfo->exa_major, pScreenInfo->exa_minor,
|
|
|
|
|
EXA_VERSION_MAJOR, EXA_VERSION_MINOR);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-01 10:56:12 +02:00
|
|
|
|
#ifdef RENDER
|
|
|
|
|
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
|
|
|
|
|
#endif
|
|
|
|
|
if (exaGeneration != serverGeneration)
|
|
|
|
|
{
|
|
|
|
|
exaScreenPrivateIndex = AllocateScreenPrivateIndex();
|
|
|
|
|
exaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
|
|
|
|
|
exaGeneration = serverGeneration;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-09 16:15:35 +02:00
|
|
|
|
pExaScr = xcalloc (sizeof (ExaScreenPrivRec), 1);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
|
2005-08-26 22:21:57 +02:00
|
|
|
|
if (!pExaScr) {
|
2006-02-16 01:14:11 +01:00
|
|
|
|
LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n",
|
|
|
|
|
pScreen->myNum);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
return FALSE;
|
2005-08-26 22:21:57 +02:00
|
|
|
|
}
|
2005-07-01 10:56:12 +02:00
|
|
|
|
|
|
|
|
|
pExaScr->info = pScreenInfo;
|
|
|
|
|
|
|
|
|
|
pScreen->devPrivates[exaScreenPrivateIndex].ptr = (pointer) pExaScr;
|
|
|
|
|
|
2006-02-16 01:14:11 +01:00
|
|
|
|
exaDDXDriverInit(pScreen);
|
|
|
|
|
|
2005-07-01 10:56:12 +02:00
|
|
|
|
/*
|
|
|
|
|
* Replace various fb screen functions
|
|
|
|
|
*/
|
2005-07-04 16:15:57 +02:00
|
|
|
|
pExaScr->SavedCloseScreen = pScreen->CloseScreen;
|
|
|
|
|
pScreen->CloseScreen = exaCloseScreen;
|
|
|
|
|
|
|
|
|
|
pExaScr->SavedCreateGC = pScreen->CreateGC;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
pScreen->CreateGC = exaCreateGC;
|
2005-07-04 16:15:57 +02:00
|
|
|
|
|
|
|
|
|
pExaScr->SavedGetImage = pScreen->GetImage;
|
|
|
|
|
pScreen->GetImage = ExaCheckGetImage;
|
|
|
|
|
|
|
|
|
|
pExaScr->SavedGetSpans = pScreen->GetSpans;
|
|
|
|
|
pScreen->GetSpans = ExaCheckGetSpans;
|
|
|
|
|
|
|
|
|
|
pExaScr->SavedCopyWindow = pScreen->CopyWindow;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
pScreen->CopyWindow = exaCopyWindow;
|
2005-07-04 16:15:57 +02:00
|
|
|
|
|
|
|
|
|
pExaScr->SavedPaintWindowBackground = pScreen->PaintWindowBackground;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
pScreen->PaintWindowBackground = exaPaintWindow;
|
2005-07-04 16:15:57 +02:00
|
|
|
|
|
|
|
|
|
pExaScr->SavedPaintWindowBorder = pScreen->PaintWindowBorder;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
pScreen->PaintWindowBorder = exaPaintWindow;
|
2005-07-04 16:15:57 +02:00
|
|
|
|
|
|
|
|
|
pScreen->BackingStoreFuncs.SaveAreas = ExaCheckSaveAreas;
|
|
|
|
|
pScreen->BackingStoreFuncs.RestoreAreas = ExaCheckRestoreAreas;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
#ifdef RENDER
|
|
|
|
|
if (ps) {
|
2005-07-04 16:15:57 +02:00
|
|
|
|
pExaScr->SavedComposite = ps->Composite;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
ps->Composite = exaComposite;
|
- Don't try to upload 0 byte-per-pixel (PICT_a1) data using
RADEONHostDataBlit.
- Disable the shortcut for switching from 3d to 3d in radeon_exa.c. It
appears that we do need the cache flush here, thought it's not clear
why. Disable the 2d to 2d shortcut while here, since I'm unsure of what
we're doing. Exposed by the following bit:
- Bug #4485: Add a new routine, exaGlyphs, to handle font drawing. Glyphs
were being accumulated in from non-migratable scratch pixmaps, causing
the destination pixmap to move towards screen but the migration
necessary for source never to happen, leading to abysmal performance.
Instead, copy the scratch glyph data into a real pixmap first, then
composite from that into the destination, allowing for migration. time
ls -lR from programs/Xserver showed 26.9% (+/- 6.3%) decrease in wall
time (n=3).
- Create exaDrawableUse* wrapping exaPixmapUse*, but which are aware of
windows needing backing store. Makes migration code prettier, and
ensures that composited windows will be migrated as normal when we turn
off cw for EXA. (issue brought up by keithp)
2005-09-17 22:02:02 +02:00
|
|
|
|
|
|
|
|
|
pExaScr->SavedGlyphs = ps->Glyphs;
|
|
|
|
|
ps->Glyphs = exaGlyphs;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-10-02 10:28:27 +02:00
|
|
|
|
miDisableCompositeWrapper(pScreen);
|
|
|
|
|
|
2005-07-01 10:56:12 +02:00
|
|
|
|
/*
|
|
|
|
|
* Hookup offscreen pixmaps
|
|
|
|
|
*/
|
2006-03-09 07:04:07 +01:00
|
|
|
|
if ((pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) &&
|
|
|
|
|
pExaScr->info->offScreenBase < pExaScr->info->memorySize)
|
2005-07-01 10:56:12 +02:00
|
|
|
|
{
|
|
|
|
|
if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex,
|
2005-08-26 22:21:57 +02:00
|
|
|
|
sizeof (ExaPixmapPrivRec))) {
|
2006-02-16 01:14:11 +01:00
|
|
|
|
LogMessage(X_WARNING,
|
|
|
|
|
"EXA(%d): Failed to allocate pixmap private\n",
|
|
|
|
|
pScreen->myNum);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
return FALSE;
|
2005-08-26 22:21:57 +02:00
|
|
|
|
}
|
2005-07-04 16:15:57 +02:00
|
|
|
|
pExaScr->SavedCreatePixmap = pScreen->CreatePixmap;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
pScreen->CreatePixmap = exaCreatePixmap;
|
2005-07-04 16:15:57 +02:00
|
|
|
|
|
|
|
|
|
pExaScr->SavedDestroyPixmap = pScreen->DestroyPixmap;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
pScreen->DestroyPixmap = exaDestroyPixmap;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-02-16 01:14:11 +01:00
|
|
|
|
LogMessage(X_INFO, "EXA(%d): No offscreen pixmaps\n", pScreen->myNum);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex, 0))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
DBG_PIXMAP(("============== %ld < %ld\n", pExaScr->info->offScreenBase,
|
|
|
|
|
pExaScr->info->memorySize));
|
|
|
|
|
if (pExaScr->info->offScreenBase < pExaScr->info->memorySize) {
|
2005-08-26 22:21:57 +02:00
|
|
|
|
if (!exaOffscreenInit (pScreen)) {
|
2006-02-16 01:14:11 +01:00
|
|
|
|
LogMessage(X_WARNING, "EXA(%d): Offscreen pixmap setup failed\n",
|
|
|
|
|
pScreen->myNum);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
return FALSE;
|
2005-08-26 22:21:57 +02:00
|
|
|
|
}
|
2005-07-01 10:56:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaDriverFini tears down EXA on a given screen.
|
|
|
|
|
*
|
|
|
|
|
* @param pScreen screen being torn down.
|
|
|
|
|
*/
|
2005-07-01 10:56:12 +02:00
|
|
|
|
void
|
|
|
|
|
exaDriverFini (ScreenPtr pScreen)
|
|
|
|
|
{
|
2005-07-04 16:15:57 +02:00
|
|
|
|
/*right now does nothing*/
|
2005-07-01 10:56:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaMarkSync() should be called after any asynchronous drawing by the hardware.
|
|
|
|
|
*
|
|
|
|
|
* @param pScreen screen which drawing occurred on
|
|
|
|
|
*
|
|
|
|
|
* exaMarkSync() sets a flag to indicate that some asynchronous drawing has
|
|
|
|
|
* happened and a WaitSync() will be necessary before relying on the contents of
|
|
|
|
|
* offscreen memory from the CPU's perspective. It also calls an optional
|
|
|
|
|
* driver MarkSync() callback, the return value of which may be used to do partial
|
|
|
|
|
* synchronization with the hardware in the future.
|
|
|
|
|
*/
|
2005-07-01 10:56:12 +02:00
|
|
|
|
void exaMarkSync(ScreenPtr pScreen)
|
|
|
|
|
{
|
|
|
|
|
ExaScreenPriv(pScreen);
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
pExaScr->info->needsSync = TRUE;
|
|
|
|
|
if (pExaScr->info->MarkSync != NULL) {
|
|
|
|
|
pExaScr->info->lastMarker = (*pExaScr->info->MarkSync)(pScreen);
|
2005-07-01 10:56:12 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-10 00:18:15 +01:00
|
|
|
|
/**
|
|
|
|
|
* exaWaitSync() ensures that all drawing has been completed.
|
|
|
|
|
*
|
|
|
|
|
* @param pScreen screen being synchronized.
|
|
|
|
|
*
|
|
|
|
|
* Calls down into the driver to ensure that all previous drawing has completed.
|
|
|
|
|
* It should always be called before relying on the framebuffer contents
|
|
|
|
|
* reflecting previous drawing, from a CPU perspective.
|
|
|
|
|
*/
|
2005-07-01 10:56:12 +02:00
|
|
|
|
void exaWaitSync(ScreenPtr pScreen)
|
|
|
|
|
{
|
|
|
|
|
ExaScreenPriv(pScreen);
|
|
|
|
|
|
2006-03-09 07:04:07 +01:00
|
|
|
|
if (pExaScr->info->needsSync && !pExaScr->swappedOut) {
|
|
|
|
|
(*pExaScr->info->WaitMarker)(pScreen, pExaScr->info->lastMarker);
|
|
|
|
|
pExaScr->info->needsSync = FALSE;
|
2005-07-01 10:56:12 +02:00
|
|
|
|
}
|
|
|
|
|
}
|