EXA: Migrate out pixmap in exaPrepareAccess.

Also fix exaFinishAccessGC not to use the same index for tile and stipple.
This commit is contained in:
Michel Dänzer 2007-09-05 20:10:09 +02:00
parent e510a77ba4
commit 8cfcf9973c
6 changed files with 41 additions and 93 deletions

View File

@ -329,14 +329,8 @@ exaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
return NULL; return NULL;
} }
/**
* exaPrepareAccess() is EXA's wrapper for the driver's PrepareAccess() handler.
*
* It deals with waiting for synchronization with the card, determining if
* PrepareAccess() is necessary, and working around PrepareAccess() failure.
*/
void void
exaPrepareAccess(DrawablePtr pDrawable, int index) ExaDoPrepareAccess(DrawablePtr pDrawable, int index)
{ {
ScreenPtr pScreen = pDrawable->pScreen; ScreenPtr pScreen = pDrawable->pScreen;
ExaScreenPriv (pScreen); ExaScreenPriv (pScreen);
@ -367,6 +361,26 @@ exaPrepareAccess(DrawablePtr pDrawable, int index)
} }
} }
/**
* exaPrepareAccess() is EXA's wrapper for the driver's PrepareAccess() handler.
*
* It deals with waiting for synchronization with the card, determining if
* PrepareAccess() is necessary, and working around PrepareAccess() failure.
*/
void
exaPrepareAccess(DrawablePtr pDrawable, int index)
{
ExaMigrationRec pixmaps[1];
pixmaps[0].as_dst = index == EXA_PREPARE_DEST;
pixmaps[0].as_src = index != EXA_PREPARE_DEST;
pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
exaDoMigration(pixmaps, 1, FALSE);
ExaDoPrepareAccess(pDrawable, index);
}
/** /**
* exaFinishAccess() is EXA's wrapper for the driver's FinishAccess() handler. * exaFinishAccess() is EXA's wrapper for the driver's FinishAccess() handler.
* *
@ -698,7 +712,7 @@ exaDriverInit (ScreenPtr pScreen,
pScreen->GetImage = exaGetImage; pScreen->GetImage = exaGetImage;
pExaScr->SavedGetSpans = pScreen->GetSpans; pExaScr->SavedGetSpans = pScreen->GetSpans;
pScreen->GetSpans = exaGetSpans; pScreen->GetSpans = ExaCheckGetSpans;
pExaScr->SavedCopyWindow = pScreen->CopyWindow; pExaScr->SavedCopyWindow = pScreen->CopyWindow;
pScreen->CopyWindow = exaCopyWindow; pScreen->CopyWindow = exaCopyWindow;

View File

@ -61,7 +61,6 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
pPixmap->drawable.width > pExaScr->info->maxX || pPixmap->drawable.width > pExaScr->info->maxX ||
pPixmap->drawable.height > pExaScr->info->maxY) pPixmap->drawable.height > pExaScr->info->maxY)
{ {
exaDoMigration (pixmaps, 1, FALSE);
ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
return; return;
} else { } else {
@ -74,7 +73,6 @@ exaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
pGC->planemask, pGC->planemask,
pGC->fgPixel)) pGC->fgPixel))
{ {
exaDoMigration (pixmaps, 1, FALSE);
ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted); ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
return; return;
} }
@ -158,11 +156,11 @@ exaDoPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
/* Don't bother with under 8bpp, XYPixmaps. */ /* Don't bother with under 8bpp, XYPixmaps. */
if (format != ZPixmap || bpp < 8) if (format != ZPixmap || bpp < 8)
goto migrate_and_fallback; goto fallback;
/* Only accelerate copies: no rop or planemask. */ /* Only accelerate copies: no rop or planemask. */
if (!EXA_PM_IS_SOLID(pDrawable, pGC->planemask) || pGC->alu != GXcopy) if (!EXA_PM_IS_SOLID(pDrawable, pGC->planemask) || pGC->alu != GXcopy)
goto migrate_and_fallback; goto fallback;
if (pExaScr->swappedOut) if (pExaScr->swappedOut)
goto fallback; goto fallback;
@ -240,9 +238,6 @@ exaDoPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
return TRUE; return TRUE;
migrate_and_fallback:
exaDoMigration (pixmaps, 1, FALSE);
fallback: fallback:
return FALSE; return FALSE;
} }
@ -468,7 +463,6 @@ exaCopyNtoN (DrawablePtr pSrcDrawable,
EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable, EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
exaDrawableLocation(pSrcDrawable), exaDrawableLocation(pSrcDrawable),
exaDrawableLocation(pDstDrawable))); exaDrawableLocation(pDstDrawable)));
exaDoMigration (pixmaps, 2, FALSE);
exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST); exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST);
exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC); exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
@ -731,15 +725,6 @@ exaPolyFillRect(DrawablePtr pDrawable,
pGC->fgPixel)) pGC->fgPixel))
{ {
fallback: fallback:
if (pGC->fillStyle == FillTiled && !pGC->tileIsPixel) {
pixmaps[1].as_dst = FALSE;
pixmaps[1].as_src = TRUE;
pixmaps[1].pPix = pGC->tile.pixmap;
exaDoMigration (pixmaps, 2, FALSE);
} else {
exaDoMigration (pixmaps, 1, FALSE);
}
ExaCheckPolyFillRect (pDrawable, pGC, nrect, prect); ExaCheckPolyFillRect (pDrawable, pGC, nrect, prect);
goto out; goto out;
} }
@ -860,7 +845,6 @@ exaSolidBoxClipped (DrawablePtr pDrawable,
{ {
EXA_FALLBACK(("to %p (%c)\n", pDrawable, EXA_FALLBACK(("to %p (%c)\n", pDrawable,
exaDrawableLocation(pDrawable))); exaDrawableLocation(pDrawable)));
exaDoMigration (pixmaps, 1, FALSE);
fallback = TRUE; fallback = TRUE;
exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel); fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
@ -969,7 +953,6 @@ exaImageGlyphBlt (DrawablePtr pDrawable,
depthMask = FbFullMask(pDrawable->depth); depthMask = FbFullMask(pDrawable->depth);
if ((pGC->planemask & depthMask) != depthMask) if ((pGC->planemask & depthMask) != depthMask)
{ {
exaDoMigration(pixmaps, 1, FALSE);
ExaCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase); ExaCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
goto damage; goto damage;
} }
@ -1004,7 +987,6 @@ exaImageGlyphBlt (DrawablePtr pDrawable,
} }
EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable))); EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
exaDoMigration(pixmaps, 1, FALSE);
exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
exaPrepareAccessGC (pGC); exaPrepareAccessGC (pGC);
@ -1146,7 +1128,6 @@ fallback:
return FALSE; return FALSE;
EXA_FALLBACK(("to %p (%c)\n", pDrawable, EXA_FALLBACK(("to %p (%c)\n", pDrawable,
exaDrawableLocation(pDrawable))); exaDrawableLocation(pDrawable)));
exaDoMigration (pixmaps, 1, FALSE);
exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
fbFillRegionSolid (pDrawable, pRegion, 0, fbFillRegionSolid (pDrawable, pRegion, 0,
fbReplicatePixel (pixel, pDrawable->bitsPerPixel)); fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
@ -1262,7 +1243,6 @@ fallback:
EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable, EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable,
exaDrawableLocation(&pTile->drawable), exaDrawableLocation(&pTile->drawable),
exaDrawableLocation(pDrawable))); exaDrawableLocation(pDrawable)));
exaDoMigration (pixmaps, 2, FALSE);
exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
exaPrepareAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC); exaPrepareAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
fbFillRegionTiled (pDrawable, pRegion, pTile); fbFillRegionTiled (pDrawable, pRegion, pTile);
@ -1349,7 +1329,6 @@ exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask, char *d) unsigned int format, unsigned long planeMask, char *d)
{ {
ExaScreenPriv (pDrawable->pScreen); ExaScreenPriv (pDrawable->pScreen);
ExaMigrationRec pixmaps[1];
PixmapPtr pPix; PixmapPtr pPix;
int xoff, yoff; int xoff, yoff;
Bool ok; Bool ok;
@ -1362,13 +1341,13 @@ exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
/* Only cover the ZPixmap, solid copy case. */ /* Only cover the ZPixmap, solid copy case. */
if (format != ZPixmap || !EXA_PM_IS_SOLID(pDrawable, planeMask)) if (format != ZPixmap || !EXA_PM_IS_SOLID(pDrawable, planeMask))
goto migrate_and_fallback; goto fallback;
/* Only try to handle the 8bpp and up cases, since we don't want to think /* Only try to handle the 8bpp and up cases, since we don't want to think
* about <8bpp. * about <8bpp.
*/ */
if (pDrawable->bitsPerPixel < 8) if (pDrawable->bitsPerPixel < 8)
goto migrate_and_fallback; goto fallback;
pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff); pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
if (pPix == NULL) if (pPix == NULL)
@ -1384,29 +1363,6 @@ exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
return; return;
} }
migrate_and_fallback:
pixmaps[0].as_dst = FALSE;
pixmaps[0].as_src = TRUE;
pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
exaDoMigration (pixmaps, 1, FALSE);
fallback: fallback:
ExaCheckGetImage (pDrawable, x, y, w, h, format, planeMask, d); ExaCheckGetImage (pDrawable, x, y, w, h, format, planeMask, d);
} }
/**
* GetSpans isn't accelerated yet, but performs migration so that we'll
* hopefully avoid the read-from-framebuffer cost.
*/
void
exaGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
int nspans, char *pdstStart)
{
ExaMigrationRec pixmaps[1];
pixmaps[0].as_dst = FALSE;
pixmaps[0].as_src = TRUE;
pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
exaDoMigration (pixmaps, 1, FALSE);
ExaCheckGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
}

View File

@ -152,7 +152,7 @@ exaCopyDirtyToSys (PixmapPtr pPixmap)
+ pBox->x1 * pPixmap->drawable.bitsPerPixel / 8, + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
pExaPixmap->sys_pitch)) pExaPixmap->sys_pitch))
{ {
exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC); ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
exaMemcpyBox (pPixmap, pBox, exaMemcpyBox (pPixmap, pBox,
pExaPixmap->fb_ptr, pExaPixmap->fb_pitch, pExaPixmap->fb_ptr, pExaPixmap->fb_pitch,
pExaPixmap->sys_ptr, pExaPixmap->sys_pitch); pExaPixmap->sys_ptr, pExaPixmap->sys_pitch);
@ -220,7 +220,7 @@ exaCopyDirtyToFb (PixmapPtr pPixmap)
+ pBox->x1 * pPixmap->drawable.bitsPerPixel / 8, + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
pExaPixmap->sys_pitch)) pExaPixmap->sys_pitch))
{ {
exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_DEST); ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_DEST);
exaMemcpyBox (pPixmap, pBox, exaMemcpyBox (pPixmap, pBox,
pExaPixmap->sys_ptr, pExaPixmap->sys_pitch, pExaPixmap->sys_ptr, pExaPixmap->sys_pitch,
pExaPixmap->fb_ptr, pExaPixmap->fb_pitch); pExaPixmap->fb_ptr, pExaPixmap->fb_pitch);
@ -471,7 +471,7 @@ exaAssertNotDirty (PixmapPtr pPixmap)
src_pitch = pExaPixmap->fb_pitch; src_pitch = pExaPixmap->fb_pitch;
cpp = pPixmap->drawable.bitsPerPixel / 8; cpp = pPixmap->drawable.bitsPerPixel / 8;
exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC); ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
while (nbox--) { while (nbox--) {
int rowbytes; int rowbytes;
@ -622,14 +622,9 @@ exaDoMigration (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
exaMoveInPixmap(pixmaps[i].pPix); exaMoveInPixmap(pixmaps[i].pPix);
} }
/* If we couldn't fit everything in, then kick back out */ /* If we couldn't fit everything in, abort */
for (i = 0; i < npixmaps; i++) { for (i = 0; i < npixmaps; i++) {
if (!exaPixmapIsOffscreen(pixmaps[i].pPix)) { if (!exaPixmapIsOffscreen(pixmaps[i].pPix)) {
EXA_FALLBACK(("Pixmap %p (%dx%d) not in fb\n", pixmaps[i].pPix,
pixmaps[i].pPix->drawable.width,
pixmaps[i].pPix->drawable.height));
for (j = 0; j < npixmaps; j++)
exaMoveOutPixmap(pixmaps[j].pPix);
return; return;
} }
} }

View File

@ -298,10 +298,6 @@ void
exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h, exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask, char *d); unsigned int format, unsigned long planeMask, char *d);
void
exaGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
int nspans, char *pdstStart);
extern const GCOps exaOps; extern const GCOps exaOps;
#ifdef MITSHM #ifdef MITSHM
@ -338,6 +334,9 @@ void
ExaOffscreenFini (ScreenPtr pScreen); ExaOffscreenFini (ScreenPtr pScreen);
/* exa.c */ /* exa.c */
void
ExaDoPrepareAccess(DrawablePtr pDrawable, int index);
void void
exaPrepareAccess(DrawablePtr pDrawable, int index); exaPrepareAccess(DrawablePtr pDrawable, int index);

View File

@ -738,7 +738,6 @@ fallback:
exaPrintCompositeFallback (op, pSrc, pMask, pDst); exaPrintCompositeFallback (op, pSrc, pMask, pDst);
#endif #endif
exaDoMigration(pixmaps, npixmaps, FALSE);
ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc, ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height); xMask, yMask, xDst, yDst, width, height);
@ -889,18 +888,13 @@ exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid *trap,
int x_off, int y_off) int x_off, int y_off)
{ {
DrawablePtr pDraw = pPicture->pDrawable; DrawablePtr pDraw = pPicture->pDrawable;
ExaMigrationRec pixmaps[1]; PixmapPtr pPixmap = exaGetDrawablePixmap(pDraw);
int xoff, yoff; int xoff, yoff;
pixmaps[0].as_dst = TRUE;
pixmaps[0].as_src = TRUE;
pixmaps[0].pPix = exaGetDrawablePixmap (pDraw);
exaDoMigration(pixmaps, 1, FALSE);
exaPrepareAccess(pDraw, EXA_PREPARE_DEST); exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
fbRasterizeTrapezoid(pPicture, trap, x_off, y_off); fbRasterizeTrapezoid(pPicture, trap, x_off, y_off);
exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff); exaGetDrawableDeltas(pDraw, pPixmap, &xoff, &yoff);
exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff, exaPixmapDirty(pPixmap, pDraw->x + xoff, pDraw->y + yoff,
pDraw->x + xoff + pDraw->width, pDraw->x + xoff + pDraw->width,
pDraw->y + yoff + pDraw->height); pDraw->y + yoff + pDraw->height);
exaFinishAccess(pDraw, EXA_PREPARE_DEST); exaFinishAccess(pDraw, EXA_PREPARE_DEST);
@ -915,18 +909,13 @@ exaAddTriangles (PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntri,
xTriangle *tris) xTriangle *tris)
{ {
DrawablePtr pDraw = pPicture->pDrawable; DrawablePtr pDraw = pPicture->pDrawable;
ExaMigrationRec pixmaps[1]; PixmapPtr pPixmap = exaGetDrawablePixmap(pDraw);
int xoff, yoff; int xoff, yoff;
pixmaps[0].as_dst = TRUE;
pixmaps[0].as_src = TRUE;
pixmaps[0].pPix = exaGetDrawablePixmap (pDraw);
exaDoMigration(pixmaps, 1, FALSE);
exaPrepareAccess(pDraw, EXA_PREPARE_DEST); exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
fbAddTriangles(pPicture, x_off, y_off, ntri, tris); fbAddTriangles(pPicture, x_off, y_off, ntri, tris);
exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff); exaGetDrawableDeltas(pDraw, pPixmap, &xoff, &yoff);
exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff, exaPixmapDirty(pPixmap, pDraw->x + xoff, pDraw->y + yoff,
pDraw->x + xoff + pDraw->width, pDraw->x + xoff + pDraw->width,
pDraw->y + yoff + pDraw->height); pDraw->y + yoff + pDraw->height);
exaFinishAccess(pDraw, EXA_PREPARE_DEST); exaFinishAccess(pDraw, EXA_PREPARE_DEST);

View File

@ -41,7 +41,7 @@ void
exaPrepareAccessGC(GCPtr pGC) exaPrepareAccessGC(GCPtr pGC)
{ {
if (pGC->stipple) if (pGC->stipple)
exaPrepareAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC); exaPrepareAccess(&pGC->stipple->drawable, EXA_PREPARE_MASK);
if (pGC->fillStyle == FillTiled) if (pGC->fillStyle == FillTiled)
exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC); exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
} }
@ -53,7 +53,7 @@ void
exaFinishAccessGC(GCPtr pGC) exaFinishAccessGC(GCPtr pGC)
{ {
if (pGC->fillStyle == FillTiled) if (pGC->fillStyle == FillTiled)
exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC); exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_MASK);
if (pGC->stipple) if (pGC->stipple)
exaFinishAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC); exaFinishAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC);
} }
@ -358,7 +358,6 @@ exaGetPixmapFirstPixel (PixmapPtr pPixmap)
void *fb; void *fb;
Bool need_finish = FALSE; Bool need_finish = FALSE;
BoxRec box; BoxRec box;
ExaMigrationRec pixmaps[1];
ExaPixmapPriv (pPixmap); ExaPixmapPriv (pPixmap);
fb = pExaPixmap->sys_ptr; fb = pExaPixmap->sys_ptr;
@ -368,10 +367,6 @@ exaGetPixmapFirstPixel (PixmapPtr pPixmap)
miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0, &box)) miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0, &box))
{ {
need_finish = TRUE; need_finish = TRUE;
pixmaps[0].as_dst = FALSE;
pixmaps[0].as_src = TRUE;
pixmaps[0].pPix = pPixmap;
exaDoMigration (pixmaps, 1, FALSE);
exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC); exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
fb = pPixmap->devPrivate.ptr; fb = pPixmap->devPrivate.ptr;
} }