Index: exa/exa.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/exa/exa.c,v retrieving revision 1.46 diff -p -u -r1.46 exa.c --- exa/exa.c 18 Apr 2006 19:14:07 -0000 1.46 +++ exa/exa.c 15 May 2006 14:44:18 -0000 @@ -122,13 +125,19 @@ exaGetDrawablePixmap(DrawablePtr pDrawab * optimizations in pixmap migration when no changes have occurred. */ void -exaDrawableDirty (DrawablePtr pDrawable) +exaDrawableDirty (DrawablePtr pDrawable, int x1, int y1, int x2, int y2) { ExaPixmapPrivPtr pExaPixmap; + RegionPtr pDamageReg; + RegionRec region = { { x1, y2, x2, y2 }, NULL }; pExaPixmap = ExaGetPixmapPriv(exaGetDrawablePixmap (pDrawable)); - if (pExaPixmap != NULL) - pExaPixmap->dirty = TRUE; + + if (!pExaPixmap || x1 >= x2 || y1 >= y2) + return; + + pDamageReg = DamageRegion(pExaPixmap->pDamage); + REGION_UNION(pScreen, pDamageReg, pDamageReg, ®ion); } static Bool @@ -149,6 +158,7 @@ exaDestroyPixmap (PixmapPtr pPixmap) pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr; pPixmap->devKind = pExaPixmap->sys_pitch; } + REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validReg); } return fbDestroyPixmap (pPixmap); } @@ -216,7 +226,20 @@ exaCreatePixmap(ScreenPtr pScreen, int w return NULL; } - pExaPixmap->dirty = FALSE; + /* Set up damage tracking */ + pExaPixmap->pDamage = DamageCreate (NULL, NULL, DamageReportNone, TRUE, + pScreen, pPixmap); + + if (pExaPixmap->pDamage == NULL) { + fbDestroyPixmap (pPixmap); + return NULL; + } + + DamageRegister (&pPixmap->drawable, pExaPixmap->pDamage); + DamageSetReportAfterOp (pExaPixmap->pDamage, TRUE); + + /* None of the pixmap bits are valid initially */ + REGION_NULL(pScreen, &pExaPixmap->validReg); return pPixmap; } @@ -334,8 +357,7 @@ exaPrepareAccess(DrawablePtr pDrawable, /** * exaFinishAccess() is EXA's wrapper for the driver's FinishAccess() handler. * - * It deals with marking drawables as dirty, and calling the driver's - * FinishAccess() only if necessary. + * It deals with calling the driver's FinishAccess() only if necessary. */ void exaFinishAccess(DrawablePtr pDrawable, int index) @@ -345,9 +367,6 @@ exaFinishAccess(DrawablePtr pDrawable, i PixmapPtr pPixmap; ExaPixmapPrivPtr pExaPixmap; - if (index == EXA_PREPARE_DEST) - exaDrawableDirty (pDrawable); - pPixmap = exaGetDrawablePixmap (pDrawable); pExaPixmap = ExaGetPixmapPriv(pPixmap); @@ -373,7 +392,7 @@ exaFinishAccess(DrawablePtr pDrawable, i * accelerated or may sync the card and fall back to fb. */ static void -exaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable) +exaValidateGC (GCPtr pGC, unsigned long changes, DrawablePtr pDrawable) { /* fbValidateGC will do direct access to pixmaps if the tiling has changed. * Preempt fbValidateGC by doing its work and masking the change out, so @@ -422,6 +441,9 @@ exaValidateGC (GCPtr pGC, Mask changes, exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC); fbPadPixmap (pGC->tile.pixmap); exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC); + exaDrawableDirty(&pGC->tile.pixmap->drawable, 0, 0, + pGC->tile.pixmap->drawable.width, + pGC->tile.pixmap->drawable.height); } /* Mask out the GCTile change notification, now that we've done FB's * job for it. Index: exa/exa_accel.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/exa/exa_accel.c,v retrieving revision 1.50 diff -p -u -r1.50 exa_accel.c --- exa/exa_accel.c 28 Apr 2006 03:27:12 -0000 1.50 +++ exa/exa_accel.c 15 May 2006 14:44:19 -0000 @@ -20,6 +20,11 @@ * 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. + * + * Authors: + * Eric Anholt + * Michel Dänzer + * */ #ifdef HAVE_DIX_CONFIG_H @@ -104,6 +109,9 @@ exaFillSpans(DrawablePtr pDrawable, GCPt (*pExaScr->info->Solid) (pPixmap, fullX1 + off_x, fullY1 + off_y, fullX2 + off_x, fullY1 + 1 + off_y); + exaDrawableDirty (pDrawable, + fullX1 + off_x, fullY1 + off_y, + fullX2 + off_x, fullY1 + 1 + off_y); } else { @@ -118,17 +126,20 @@ exaFillSpans(DrawablePtr pDrawable, GCPt partX2 = pbox->x2; if (partX2 > fullX2) partX2 = fullX2; - if (partX2 > partX1) + if (partX2 > partX1) { (*pExaScr->info->Solid) (pPixmap, partX1 + off_x, fullY1 + off_y, partX2 + off_x, fullY1 + 1 + off_y); + exaDrawableDirty (pDrawable, + partX1 + off_x, fullY1 + off_y, + partX2 + off_x, fullY1 + 1 + off_y); + } } pbox++; } } } (*pExaScr->info->DoneSolid) (pPixmap); - exaDrawableDirty (pDrawable); exaMarkSync(pScreen); } @@ -222,8 +233,8 @@ exaPutImage (DrawablePtr pDrawable, GCPt exaFinishAccess(pDrawable, EXA_PREPARE_DEST); } + exaDrawableDirty(pDrawable, x1 + xoff, y1 + yoff, x2 + xoff, y2 + yoff); } - exaDrawableDirty(pDrawable); return; @@ -351,11 +362,13 @@ exaCopyNtoNTwoDir (DrawablePtr pSrcDrawa dst_off_y + pbox->y1 + i, pbox->x2 - pbox->x1, 1); } + exaDrawableDirty(pDstDrawable, + dst_off_x + pbox->x1, dst_off_y + pbox->y1, + dst_off_x + pbox->x2, dst_off_y + pbox->y2); } if (dirsetup != 0) pExaScr->info->DoneCopy(pDstPixmap); exaMarkSync(pDstDrawable->pScreen); - exaDrawableDirty(pDstDrawable); return TRUE; } @@ -423,11 +436,13 @@ exaCopyNtoN (DrawablePtr pSrcDrawable pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + exaDrawableDirty (pDstDrawable, + pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, + pbox->x2 + dst_off_x, pbox->y2 + dst_off_y); pbox++; } (*pExaScr->info->DoneCopy) (pDstPixmap); exaMarkSync(pDstDrawable->pScreen); - exaDrawableDirty (pDstDrawable); return; } @@ -442,6 +457,13 @@ fallback: bitplane, closure); exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC); exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST); + while (nbox--) + { + exaDrawableDirty (pDstDrawable, + pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, + pbox->x2 + dst_off_x, pbox->y2 + dst_off_y); + pbox++; + } } RegionPtr @@ -706,15 +728,18 @@ exaPolyFillRect(DrawablePtr pDrawable, pbox++; - if (partX1 < partX2 && partY1 < partY2) + if (partX1 < partX2 && partY1 < partY2) { (*pExaScr->info->Solid) (pPixmap, partX1 + xoff, partY1 + yoff, partX2 + xoff, partY2 + yoff); + exaDrawableDirty (pDrawable, + partX1 + xoff, partY1 + yoff, + partX2 + xoff, partY2 + yoff); + } } } } (*pExaScr->info->DoneSolid) (pPixmap); - exaDrawableDirty (pDrawable); exaMarkSync(pDrawable->pScreen); } @@ -735,11 +760,15 @@ exaSolidBoxClipped (DrawablePtr pDrawabl int xoff, yoff; int partX1, partX2, partY1, partY2; ExaMigrationRec pixmaps[1]; + Bool fallback = FALSE; pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable); - + + /* We need to initialize x/yoff for tracking damage in the fallback case */ + pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff); + if (pExaScr->swappedOut || pDrawable->width > pExaScr->info->maxX || pDrawable->height > pExaScr->info->maxY) @@ -750,19 +779,19 @@ exaSolidBoxClipped (DrawablePtr pDrawabl exaDoMigration (pixmaps, 1, TRUE); } - if (!(pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) || + if (!pPixmap || !(*pExaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg)) { fallback: EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable))); + fallback = TRUE; exaPrepareAccess (pDrawable, EXA_PREPARE_DEST); fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel); fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2, fbAnd (GXcopy, fg, pm), fbXor (GXcopy, fg, pm)); exaFinishAccess (pDrawable, EXA_PREPARE_DEST); - return; } for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip); nbox--; @@ -790,12 +819,19 @@ fallback: if (partY2 <= partY1) continue; - (*pExaScr->info->Solid) (pPixmap, - partX1 + xoff, partY1 + yoff, - partX2 + xoff, partY2 + yoff); + if (!fallback) + (*pExaScr->info->Solid) (pPixmap, + partX1 + xoff, partY1 + yoff, + partX2 + xoff, partY2 + yoff); + exaDrawableDirty (pDrawable, + partX1 + xoff, partY1 + yoff, + partX2 + xoff, partY2 + yoff); } + + if (fallback) + return; + (*pExaScr->info->DoneSolid) (pPixmap); - exaDrawableDirty (pDrawable); exaMarkSync(pDrawable->pScreen); } @@ -928,6 +964,8 @@ exaImageGlyphBlt (DrawablePtr pDrawable, gStride, 0); } + exaDrawableDirty(pDrawable, gx + dstXoff, gy + dstYoff, + gx + dstXoff + gWidth, gy + dstYoff + gHeight); } x += pci->metrics.characterWidth; } @@ -997,6 +1035,8 @@ exaFillRegionSolid (DrawablePtr pDrawabl PixmapPtr pPixmap; int xoff, yoff; ExaMigrationRec pixmaps[1]; + int nbox = REGION_NUM_RECTS (pRegion); + BoxPtr pBox = REGION_RECTS (pRegion); pixmaps[0].as_dst = TRUE; pixmaps[0].as_src = FALSE; @@ -1014,19 +1054,18 @@ exaFillRegionSolid (DrawablePtr pDrawabl if ((pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) && (*pExaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel)) { - int nbox = REGION_NUM_RECTS (pRegion); - BoxPtr pBox = REGION_RECTS (pRegion); - while (nbox--) { (*pExaScr->info->Solid) (pPixmap, pBox->x1 + xoff, pBox->y1 + yoff, pBox->x2 + xoff, pBox->y2 + yoff); + exaDrawableDirty (pDrawable, + pBox->x1 + xoff, pBox->y1 + yoff, + pBox->x2 + xoff, pBox->y2 + yoff); pBox++; } (*pExaScr->info->DoneSolid) (pPixmap); exaMarkSync(pDrawable->pScreen); - exaDrawableDirty (pDrawable); } else { @@ -1037,6 +1076,13 @@ fallback: fbFillRegionSolid (pDrawable, pRegion, 0, fbReplicatePixel (pixel, pDrawable->bitsPerPixel)); exaFinishAccess (pDrawable, EXA_PREPARE_DEST); + while (nbox--) + { + exaDrawableDirty (pDrawable, + pBox->x1 + xoff, pBox->y1 + yoff, + pBox->x2 + xoff, pBox->y2 + yoff); + pBox++; + } } } @@ -1053,6 +1099,8 @@ exaFillRegionTiled (DrawablePtr pDrawabl int xoff, yoff; int tileWidth, tileHeight; ExaMigrationRec pixmaps[2]; + int nbox = REGION_NUM_RECTS (pRegion); + BoxPtr pBox = REGION_RECTS (pRegion); tileWidth = pTile->drawable.width; tileHeight = pTile->drawable.height; @@ -1072,6 +1120,9 @@ exaFillRegionTiled (DrawablePtr pDrawabl pixmaps[1].as_src = TRUE; pixmaps[1].pPix = pTile; + /* We need to initialize x/yoff for tracking damage in the fallback case */ + pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff); + if (pDrawable->width > pExaScr->info->maxX || pDrawable->height > pExaScr->info->maxY || tileWidth > pExaScr->info->maxX || @@ -1083,7 +1134,6 @@ exaFillRegionTiled (DrawablePtr pDrawabl exaDoMigration (pixmaps, 2, TRUE); } - pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff); if (!pPixmap) goto fallback; @@ -1093,9 +1143,6 @@ exaFillRegionTiled (DrawablePtr pDrawabl if ((*pExaScr->info->PrepareCopy) (pTile, pPixmap, 0, 0, GXcopy, FB_ALLONES)) { - int nbox = REGION_NUM_RECTS (pRegion); - BoxPtr pBox = REGION_RECTS (pRegion); - while (nbox--) { int height = pBox->y2 - pBox->y1; @@ -1130,11 +1177,12 @@ exaFillRegionTiled (DrawablePtr pDrawabl dstY += h; tileY = 0; } + exaDrawableDirty (pDrawable, pBox->x1 + xoff, pBox->y1 + yoff, + pBox->x2 + xoff, pBox->y2 + yoff); pBox++; } (*pExaScr->info->DoneCopy) (pPixmap); exaMarkSync(pDrawable->pScreen); - exaDrawableDirty (pDrawable); return; } @@ -1147,6 +1195,12 @@ fallback: fbFillRegionTiled (pDrawable, pRegion, pTile); exaFinishAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC); exaFinishAccess (pDrawable, EXA_PREPARE_DEST); + while (nbox--) + { + exaDrawableDirty (pDrawable, pBox->x1 + xoff, pBox->y1 + yoff, + pBox->x2 + xoff, pBox->y2 + yoff); + pBox++; + } } void Index: exa/exa_migration.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/exa/exa_migration.c,v retrieving revision 1.46 diff -p -u -r1.46 exa_migration.c --- exa/exa_migration.c 28 Apr 2006 03:26:30 -0000 1.46 +++ exa/exa_migration.c 15 May 2006 14:44:20 -0000 @@ -22,6 +22,7 @@ * * Authors: * Eric Anholt + * Michel Dänzer * */ @@ -58,6 +59,27 @@ exaPixmapIsPinned (PixmapPtr pPix) } /** + * The fallback path for UTS/DFS failing is to just memcpy. exaCopyDirtyToSys + * and exaCopyDirtyToFb both needed to do this loop. + */ +static void +exaMemcpyBox (PixmapPtr pPixmap, BoxPtr pbox, CARD8 *src, int src_pitch, + CARD8 *dst, int dst_pitch) + { + int i, cpp = pPixmap->drawable.bitsPerPixel / 8; + int bytes = (pbox->x2 - pbox->x1) * cpp; + + src += pbox->y1 * src_pitch + pbox->x1 * cpp; + dst += pbox->y1 * dst_pitch + pbox->x1 * cpp; + + for (i = pbox->y2 - pbox->y1; i; i--) { + memcpy (dst, src, bytes); + src += src_pitch; + dst += dst_pitch; + } +} + +/** * Returns TRUE if the pixmap is dirty (has been modified in its current * location compared to the other), or lacks a private for tracking * dirtiness. @@ -67,7 +89,8 @@ exaPixmapIsDirty (PixmapPtr pPix) { ExaPixmapPriv (pPix); - return pExaPixmap == NULL || pExaPixmap->dirty == TRUE; + return pExaPixmap == NULL || + REGION_NOTEMPTY (pScreen, DamageRegion(pExaPixmap->pDamage)); } /** @@ -98,43 +121,42 @@ exaCopyDirtyToSys (PixmapPtr pPixmap) { ExaScreenPriv (pPixmap->drawable.pScreen); ExaPixmapPriv (pPixmap); + RegionPtr pRegion = DamageRegion (pExaPixmap->pDamage); CARD8 *save_ptr; int save_pitch; - - if (!pExaPixmap->dirty) - return; + BoxPtr pBox = REGION_RECTS(pRegion); + int nbox = REGION_NUM_RECTS(pRegion); save_ptr = pPixmap->devPrivate.ptr; save_pitch = pPixmap->devKind; pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr; pPixmap->devKind = pExaPixmap->fb_pitch; - if (pExaScr->info->DownloadFromScreen == NULL || - !pExaScr->info->DownloadFromScreen (pPixmap, - 0, - 0, - pPixmap->drawable.width, - pPixmap->drawable.height, - pExaPixmap->sys_ptr, - pExaPixmap->sys_pitch)) - { - char *src, *dst; - int src_pitch, dst_pitch, i, bytes; - - exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC); - - dst = pExaPixmap->sys_ptr; - dst_pitch = pExaPixmap->sys_pitch; - src = pExaPixmap->fb_ptr; - src_pitch = pExaPixmap->fb_pitch; - bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch; - - for (i = 0; i < pPixmap->drawable.height; i++) { - memcpy (dst, src, bytes); - dst += dst_pitch; - src += src_pitch; + while (nbox--) { + pBox->x2 = min(pBox->x2, pPixmap->drawable.width); + pBox->y2 = min(pBox->y2, pPixmap->drawable.height); + + if (pBox->x1 >= pBox->x2 || pBox->y1 >= pBox->y2) + continue; + + if (pExaScr->info->DownloadFromScreen == NULL || + !pExaScr->info->DownloadFromScreen (pPixmap, + pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, + pBox->y2 - pBox->y1, + pExaPixmap->sys_ptr + + pBox->y1 * pExaPixmap->sys_pitch + + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8, + pExaPixmap->sys_pitch)) + { + exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC); + exaMemcpyBox (pPixmap, pBox, + pExaPixmap->fb_ptr, pExaPixmap->fb_pitch, + pExaPixmap->sys_ptr, pExaPixmap->sys_pitch); + exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC); } - exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC); + + pBox++; } /* Make sure the bits have actually landed, since we don't necessarily sync @@ -145,7 +167,10 @@ exaCopyDirtyToSys (PixmapPtr pPixmap) pPixmap->devPrivate.ptr = save_ptr; pPixmap->devKind = save_pitch; - pExaPixmap->dirty = FALSE; + /* The previously damaged bits are now no longer damaged but valid */ + REGION_UNION(pPixmap->drawable.pScreen, + &pExaPixmap->validReg, &pExaPixmap->validReg, pRegion); + DamageEmpty (pExaPixmap->pDamage); } /** @@ -158,49 +183,51 @@ exaCopyDirtyToFb (PixmapPtr pPixmap) { ExaScreenPriv (pPixmap->drawable.pScreen); ExaPixmapPriv (pPixmap); + RegionPtr pRegion = DamageRegion (pExaPixmap->pDamage); CARD8 *save_ptr; int save_pitch; - - if (!pExaPixmap->dirty) - return; + BoxPtr pBox = REGION_RECTS(pRegion); + int nbox = REGION_NUM_RECTS(pRegion); save_ptr = pPixmap->devPrivate.ptr; save_pitch = pPixmap->devKind; pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr; pPixmap->devKind = pExaPixmap->fb_pitch; - if (pExaScr->info->UploadToScreen == NULL || - !pExaScr->info->UploadToScreen (pPixmap, - 0, - 0, - pPixmap->drawable.width, - pPixmap->drawable.height, - pExaPixmap->sys_ptr, - pExaPixmap->sys_pitch)) - { - char *src, *dst; - int src_pitch, dst_pitch, i, bytes; - - exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_DEST); - - dst = pExaPixmap->fb_ptr; - dst_pitch = pExaPixmap->fb_pitch; - src = pExaPixmap->sys_ptr; - src_pitch = pExaPixmap->sys_pitch; - bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch; - - for (i = 0; i < pPixmap->drawable.height; i++) { - memcpy (dst, src, bytes); - dst += dst_pitch; - src += src_pitch; + while (nbox--) { + pBox->x2 = min(pBox->x2, pPixmap->drawable.width); + pBox->y2 = min(pBox->y2, pPixmap->drawable.height); + + if (pBox->x1 >= pBox->x2 || pBox->y1 >= pBox->y2) + continue; + + if (pExaScr->info->UploadToScreen == NULL || + !pExaScr->info->UploadToScreen (pPixmap, + pBox->x1, pBox->y1, + pBox->x2 - pBox->x1, + pBox->y2 - pBox->y1, + pExaPixmap->sys_ptr + + pBox->y1 * pExaPixmap->sys_pitch + + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8, + pExaPixmap->sys_pitch)) + { + exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_DEST); + exaMemcpyBox (pPixmap, pBox, + pExaPixmap->sys_ptr, pExaPixmap->sys_pitch, + pExaPixmap->fb_ptr, pExaPixmap->fb_pitch); + exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_DEST); } - exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_DEST); + + pBox++; } pPixmap->devPrivate.ptr = save_ptr; pPixmap->devKind = save_pitch; - pExaPixmap->dirty = FALSE; + /* The previously damaged bits are now no longer damaged but valid */ + REGION_UNION(pPixmap->drawable.pScreen, + &pExaPixmap->validReg, &pExaPixmap->validReg, pRegion); + DamageEmpty (pExaPixmap->pDamage); } /** @@ -213,6 +240,7 @@ exaPixmapSave (ScreenPtr pScreen, ExaOff { PixmapPtr pPixmap = area->privData; ExaPixmapPriv(pPixmap); + RegionPtr pDamageReg = DamageRegion(pExaPixmap->pDamage); DBG_MIGRATE (("Save %p (%p) (%dx%d) (%c)\n", pPixmap, (void*)(ExaGetPixmapPriv(pPixmap)->area ? @@ -231,10 +259,9 @@ exaPixmapSave (ScreenPtr pScreen, ExaOff pExaPixmap->fb_ptr = NULL; pExaPixmap->area = NULL; - /* Mark it dirty now, to say that there is important data in the - * system-memory copy. - */ - pExaPixmap->dirty = TRUE; + /* Mark all valid bits as damaged, so they'll get copied to FB next time */ + REGION_UNION(pPixmap->drawable.pScreen, pDamageReg, pDamageReg, + &pExaPixmap->validReg); } /** @@ -413,30 +440,55 @@ exaMigrateTowardSys (PixmapPtr pPixmap) * If the pixmap has both a framebuffer and system memory copy, this function * asserts that both of them are the same. */ -static void +static Bool exaAssertNotDirty (PixmapPtr pPixmap) { ExaPixmapPriv (pPixmap); CARD8 *dst, *src; - int dst_pitch, src_pitch, data_row_bytes, y; + RegionPtr pValidReg = &pExaPixmap->validReg; + int dst_pitch, src_pitch, cpp, y, nbox = REGION_NUM_RECTS(pValidReg); + BoxPtr pBox = REGION_RECTS(pValidReg); + Bool ret = TRUE; if (pExaPixmap == NULL || pExaPixmap->fb_ptr == NULL) - return; + return ret; dst = pExaPixmap->sys_ptr; dst_pitch = pExaPixmap->sys_pitch; src = pExaPixmap->fb_ptr; src_pitch = pExaPixmap->fb_pitch; - data_row_bytes = pPixmap->drawable.width * - pPixmap->drawable.bitsPerPixel / 8; + cpp = pPixmap->drawable.bitsPerPixel / 8; exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC); - for (y = 0; y < pPixmap->drawable.height; y++) { - if (memcmp(dst, src, data_row_bytes) != 0) { - abort(); - } + while (nbox--) { + int rowbytes; + + pBox->x2 = min(pBox->x2, pPixmap->drawable.width); + pBox->y2 = min(pBox->y2, pPixmap->drawable.height); + + if (pBox->x1 >= pBox->x2 || pBox->y1 >= pBox->y2) + continue; + + rowbytes = (pBox->x2 - pBox->x1) * cpp; + src += pBox->y1 * src_pitch + pBox->x1 * cpp; + dst += pBox->y1 * dst_pitch + pBox->x1 * cpp; + + for (y = pBox->y2 - pBox->y1; y; y--) { + if (memcmp(dst + pBox->y1 * dst_pitch + pBox->x1 * cpp, + src + pBox->y1 * src_pitch + pBox->x1 * cpp, + (pBox->x2 - pBox->x1) * cpp) != 0) { + ret = FALSE; + break; + } + src += src_pitch; + dst += dst_pitch; + } + src -= pBox->y1 * src_pitch + pBox->x1 * cpp; + dst -= pBox->y1 * dst_pitch + pBox->x1 * cpp; } exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC); + + return ret; } /** @@ -460,8 +512,9 @@ exaDoMigration (ExaMigrationPtr pixmaps, */ if (pExaScr->checkDirtyCorrectness) { for (i = 0; i < npixmaps; i++) { - if (!exaPixmapIsDirty (pixmaps[i].pPix)) - exaAssertNotDirty (pixmaps[i].pPix); + if (!exaPixmapIsDirty (pixmaps[i].pPix) && + !exaAssertNotDirty (pixmaps[i].pPix)) + ErrorF("%s: Pixmap %d dirty but not marked as such!\n", __func__, i); } } /* If anything is pinned in system memory, we won't be able to Index: exa/exa_offscreen.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/exa/exa_offscreen.c,v retrieving revision 1.19 diff -p -u -r1.19 exa_offscreen.c --- exa/exa_offscreen.c 31 Mar 2006 19:25:42 -0000 1.19 +++ exa/exa_offscreen.c 15 May 2006 14:44:20 -0000 @@ -390,6 +392,7 @@ ExaOffscreenMarkUsed (PixmapPtr pPixmap) if (area->state == ExaOffscreenRemovable) area->score = (area->score * 7) / 8; } + iter = 0; } } Index: exa/exa_priv.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/exa/exa_priv.h,v retrieving revision 1.28 diff -p -u -r1.28 exa_priv.h --- exa/exa_priv.h 27 Apr 2006 20:27:27 -0000 1.28 +++ exa/exa_priv.h 15 May 2006 14:44:20 -0000 @@ -51,6 +51,7 @@ #ifdef RENDER #include "fbpict.h" #endif +#include "damage.h" #define DEBUG_TRACE_FALL 0 #define DEBUG_MIGRATE 0 @@ -168,16 +169,16 @@ typedef struct { unsigned int fb_size; /**< size of pixmap in framebuffer memory */ /** - * If area is NULL, then dirty == TRUE means that the pixmap has been - * modified, so the contents are defined. Used to avoid uploads of - * undefined data. - * - * If area is non-NULL, then dirty == TRUE means that the pixmap data at - * pPixmap->devPrivate.ptr (either fb_ptr or sys_ptr) has been changed - * compared to the copy in the other location. This is used to avoid - * uploads/downloads of unmodified data. + * The damage record contains the areas of the pixmap's current location + * (framebuffer or system) that have been damaged compared to the other + * location. */ - Bool dirty; + DamagePtr pDamage; + /** + * The valid region marks the valid bits of a drawable (at least, as it's + * derived from damage, which may be overreported). + */ + RegionRec validReg; } ExaPixmapPrivRec, *ExaPixmapPrivPtr; typedef struct _ExaMigrationRec { @@ -347,7 +348,7 @@ void exaFinishAccess(DrawablePtr pDrawable, int index); void -exaDrawableDirty(DrawablePtr pDrawable); +exaDrawableDirty(DrawablePtr pDrawable, int x1, int y1, int x2, int y2); Bool exaDrawableIsOffscreen (DrawablePtr pDrawable); Index: exa/exa_render.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/exa/exa_render.c,v retrieving revision 1.32 diff -p -u -r1.32 exa_render.c --- exa/exa_render.c 27 Apr 2006 20:27:27 -0000 1.32 +++ exa/exa_render.c 15 May 2006 14:44:21 -0000 @@ -298,12 +298,14 @@ exaTryDriverSolidFill(PicturePtr pSrc, (*pExaScr->info->Solid) (pDstPix, pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, pbox->x2 + dst_off_x, pbox->y2 + dst_off_y); + exaDrawableDirty (pDst->pDrawable, + pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, + pbox->x2 + dst_off_x, pbox->y2 + dst_off_y); pbox++; } (*pExaScr->info->DoneSolid) (pDstPix); exaMarkSync(pDst->pDrawable->pScreen); - exaDrawableDirty (pDst->pDrawable); REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); return 1; @@ -437,12 +439,14 @@ exaTryDriverComposite(CARD8 op, pbox->y1 + dst_off_y, pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); + exaDrawableDirty (pDst->pDrawable, + pbox->x1 + dst_off_x, pbox->y1 + dst_off_y, + pbox->x2 + dst_off_x, pbox->y2 + dst_off_y); pbox++; } (*pExaScr->info->DoneComposite) (pDstPix); exaMarkSync(pDst->pDrawable->pScreen); - exaDrawableDirty (pDst->pDrawable); REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); return 1; @@ -649,6 +653,8 @@ exaRasterizeTrapezoid (PicturePtr pPictu exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST); fbRasterizeTrapezoid(pPicture, trap, x_off, y_off); exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST); + exaDrawableDirty(pPicture->pDrawable, 0, 0, + pPicture->pDrawable->width, pPicture->pDrawable->height); } /** @@ -669,6 +675,8 @@ exaAddTriangles (PicturePtr pPicture, IN exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST); fbAddTriangles(pPicture, x_off, y_off, ntri, tris); exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST); + exaDrawableDirty(pPicture->pDrawable, 0, 0, + pPicture->pDrawable->width, pPicture->pDrawable->height); } /** @@ -958,7 +966,8 @@ exaGlyphs (CARD8 op, exaCopyArea (&pScratchPixmap->drawable, &pPixmap->drawable, pGC, 0, 0, glyph->info.width, glyph->info.height, 0, 0); } else { - exaDrawableDirty (&pPixmap->drawable); + exaDrawableDirty (&pPixmap->drawable, 0, 0, + glyph->info.width, glyph->info.height); } if (maskFormat)