2006-11-26 11:13:41 -07:00
|
|
|
/*
|
2011-11-05 07:32:40 -06:00
|
|
|
* Copyright © 2006 Intel Corporation
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Eric Anholt <eric@anholt.net>
|
2011-11-05 07:32:40 -06:00
|
|
|
* Michel Dänzer <michel@tungstengraphics.com>
|
2006-11-26 11:13:41 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "exa_priv.h"
|
|
|
|
#include "exa.h"
|
|
|
|
|
|
|
|
#if DEBUG_MIGRATE
|
|
|
|
#define DBG_MIGRATE(a) ErrorF a
|
|
|
|
#else
|
|
|
|
#define DBG_MIGRATE(a)
|
|
|
|
#endif
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
/**
|
|
|
|
* The fallback path for UTS/DFS failing is to just memcpy. exaCopyDirtyToSys
|
|
|
|
* and exaCopyDirtyToFb both needed to do this loop.
|
|
|
|
*/
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaMemcpyBox(PixmapPtr pPixmap, BoxPtr pbox, CARD8 *src, int src_pitch,
|
|
|
|
CARD8 *dst, int dst_pitch)
|
|
|
|
{
|
2007-11-24 10:55:21 -07:00
|
|
|
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--) {
|
2012-06-10 07:21:05 -06:00
|
|
|
memcpy(dst, src, bytes);
|
|
|
|
src += src_pitch;
|
|
|
|
dst += dst_pitch;
|
2007-11-24 10:55:21 -07:00
|
|
|
}
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
exaPixmapIsDirty(PixmapPtr pPix)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ExaPixmapPriv(pPix);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (pExaPixmap == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
EXA_FatalErrorDebugWithRet(("EXA bug: exaPixmapIsDirty was called on a non-exa pixmap.\n"), TRUE);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (!pExaPixmap->pDamage)
|
2012-06-10 07:21:05 -06:00
|
|
|
return FALSE;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
return RegionNotEmpty(DamageRegion(pExaPixmap->pDamage)) ||
|
2012-06-10 07:21:05 -06:00
|
|
|
!RegionEqual(&pExaPixmap->validSys, &pExaPixmap->validFB);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns TRUE if the pixmap is either pinned in FB, or has a sufficient score
|
|
|
|
* to be considered "should be in framebuffer". That's just anything that has
|
|
|
|
* had more acceleration than fallbacks, or has no score yet.
|
|
|
|
*
|
|
|
|
* Only valid if using a migration scheme that tracks score.
|
|
|
|
*/
|
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
exaPixmapShouldBeInFB(PixmapPtr pPix)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ExaPixmapPriv(pPix);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (exaPixmapIsPinned(pPix))
|
|
|
|
return TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
return pExaPixmap->score >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the pixmap is currently dirty, this copies at least the dirty area from
|
2008-11-02 08:26:08 -07:00
|
|
|
* FB to system or vice versa. Both areas must be allocated.
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
|
|
|
static void
|
2008-11-02 08:26:08 -07:00
|
|
|
exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
|
2012-06-10 07:21:05 -06:00
|
|
|
Bool (*transfer) (PixmapPtr pPix, int x, int y, int w, int h,
|
|
|
|
char *sys, int sys_pitch), int fallback_index,
|
|
|
|
void (*sync) (ScreenPtr pScreen))
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
PixmapPtr pPixmap = migrate->pPix;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
ExaPixmapPriv(pPixmap);
|
|
|
|
RegionPtr damage = DamageRegion(pExaPixmap->pDamage);
|
2008-11-02 08:26:08 -07:00
|
|
|
RegionRec CopyReg;
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool save_use_gpu_copy;
|
2006-11-26 11:13:41 -07:00
|
|
|
int save_pitch;
|
2008-11-02 08:26:08 -07:00
|
|
|
BoxPtr pBox;
|
|
|
|
int nbox;
|
|
|
|
Bool access_prepared = FALSE;
|
2009-01-12 13:17:47 -07:00
|
|
|
Bool need_sync = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/* Damaged bits are valid in current copy but invalid in other one */
|
2010-07-27 13:02:24 -06:00
|
|
|
if (pExaPixmap->use_gpu_copy) {
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionUnion(&pExaPixmap->validFB, &pExaPixmap->validFB, damage);
|
|
|
|
RegionSubtract(&pExaPixmap->validSys, &pExaPixmap->validSys, damage);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RegionUnion(&pExaPixmap->validSys, &pExaPixmap->validSys, damage);
|
|
|
|
RegionSubtract(&pExaPixmap->validFB, &pExaPixmap->validFB, damage);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionEmpty(damage);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/* Copy bits valid in source but not in destination */
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionNull(&CopyReg);
|
|
|
|
RegionSubtract(&CopyReg, pValidSrc, pValidDst);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (migrate->as_dst) {
|
2012-06-10 07:21:05 -06:00
|
|
|
ExaScreenPriv(pPixmap->drawable.pScreen);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* XXX: The pending damage region will be marked as damaged after the
|
|
|
|
* operation, so it should serve as an upper bound for the region that
|
|
|
|
* needs to be synchronized for the operation. Unfortunately, this
|
|
|
|
* causes corruption in some cases, e.g. when starting compiz. See
|
|
|
|
* https://bugs.freedesktop.org/show_bug.cgi?id=12916 .
|
|
|
|
*/
|
|
|
|
if (pExaScr->optimize_migration) {
|
|
|
|
RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
#if DEBUG_MIGRATE
|
2012-06-10 07:21:05 -06:00
|
|
|
if (RegionNil(pending_damage)) {
|
|
|
|
static Bool firsttime = TRUE;
|
|
|
|
|
|
|
|
if (firsttime) {
|
|
|
|
ErrorF("%s: Pending damage region empty!\n", __func__);
|
|
|
|
firsttime = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2009-09-06 13:44:18 -06:00
|
|
|
#endif
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Try to prevent destination valid region from growing too many
|
|
|
|
* rects by filling it up to the extents of the union of the
|
|
|
|
* destination valid region and the pending damage region.
|
|
|
|
*/
|
|
|
|
if (RegionNumRects(pValidDst) > 10) {
|
|
|
|
BoxRec box;
|
|
|
|
BoxPtr pValidExt, pDamageExt;
|
|
|
|
RegionRec closure;
|
|
|
|
|
|
|
|
pValidExt = RegionExtents(pValidDst);
|
|
|
|
pDamageExt = RegionExtents(pending_damage);
|
|
|
|
|
|
|
|
box.x1 = min(pValidExt->x1, pDamageExt->x1);
|
|
|
|
box.y1 = min(pValidExt->y1, pDamageExt->y1);
|
|
|
|
box.x2 = max(pValidExt->x2, pDamageExt->x2);
|
|
|
|
box.y2 = max(pValidExt->y2, pDamageExt->y2);
|
|
|
|
|
|
|
|
RegionInit(&closure, &box, 0);
|
|
|
|
RegionIntersect(&CopyReg, &CopyReg, &closure);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
RegionIntersect(&CopyReg, &CopyReg, pending_damage);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The caller may provide a region to be subtracted from the calculated
|
|
|
|
* dirty region. This is to avoid migration of bits that don't
|
|
|
|
* contribute to the result of the operation.
|
|
|
|
*/
|
|
|
|
if (migrate->pReg)
|
|
|
|
RegionSubtract(&CopyReg, &CopyReg, migrate->pReg);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* The caller may restrict the region to be migrated for source pixmaps
|
|
|
|
* to what's relevant for the operation.
|
|
|
|
*/
|
|
|
|
if (migrate->pReg)
|
|
|
|
RegionIntersect(&CopyReg, &CopyReg, migrate->pReg);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pBox = RegionRects(&CopyReg);
|
|
|
|
nbox = RegionNumRects(&CopyReg);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
save_use_gpu_copy = pExaPixmap->use_gpu_copy;
|
2006-11-26 11:13:41 -07:00
|
|
|
save_pitch = pPixmap->devKind;
|
2010-07-27 13:02:24 -06:00
|
|
|
pExaPixmap->use_gpu_copy = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
pPixmap->devKind = pExaPixmap->fb_pitch;
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
while (nbox--) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pBox->x1 = max(pBox->x1, 0);
|
|
|
|
pBox->y1 = max(pBox->y1, 0);
|
|
|
|
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 (!transfer || !transfer(pPixmap,
|
|
|
|
pBox->x1, pBox->y1,
|
|
|
|
pBox->x2 - pBox->x1,
|
|
|
|
pBox->y2 - pBox->y1,
|
|
|
|
(char *) (pExaPixmap->sys_ptr
|
|
|
|
+ pBox->y1 * pExaPixmap->sys_pitch
|
|
|
|
+
|
|
|
|
pBox->x1 *
|
|
|
|
pPixmap->drawable.bitsPerPixel /
|
|
|
|
8), pExaPixmap->sys_pitch)) {
|
|
|
|
if (!access_prepared) {
|
|
|
|
ExaDoPrepareAccess(pPixmap, fallback_index);
|
|
|
|
access_prepared = TRUE;
|
|
|
|
}
|
|
|
|
if (fallback_index == EXA_PREPARE_DEST) {
|
|
|
|
exaMemcpyBox(pPixmap, pBox,
|
|
|
|
pExaPixmap->sys_ptr, pExaPixmap->sys_pitch,
|
|
|
|
pPixmap->devPrivate.ptr, pPixmap->devKind);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
exaMemcpyBox(pPixmap, pBox,
|
|
|
|
pPixmap->devPrivate.ptr, pPixmap->devKind,
|
|
|
|
pExaPixmap->sys_ptr, pExaPixmap->sys_pitch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
need_sync = TRUE;
|
|
|
|
|
|
|
|
pBox++;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
pExaPixmap->use_gpu_copy = save_use_gpu_copy;
|
2006-11-26 11:13:41 -07:00
|
|
|
pPixmap->devKind = save_pitch;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* Try to prevent source valid region from growing too many rects by
|
|
|
|
* removing parts of it which are also in the destination valid region.
|
|
|
|
* Removing anything beyond that would lead to data loss.
|
|
|
|
*/
|
2010-12-05 08:36:02 -07:00
|
|
|
if (RegionNumRects(pValidSrc) > 20)
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionSubtract(pValidSrc, pValidSrc, pValidDst);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/* The copied bits are now valid in destination */
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionUnion(pValidDst, pValidDst, &CopyReg);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionUninit(&CopyReg);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (access_prepared)
|
2012-06-10 07:21:05 -06:00
|
|
|
exaFinishAccess(&pPixmap->drawable, fallback_index);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (need_sync && sync)
|
2012-06-10 07:21:05 -06:00
|
|
|
sync(pPixmap->drawable.pScreen);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-11-02 08:26:08 -07:00
|
|
|
* If the pixmap is currently dirty, this copies at least the dirty area from
|
|
|
|
* the framebuffer memory copy to the system memory copy. Both areas must be
|
|
|
|
* allocated.
|
2006-11-26 11:13:41 -07:00
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaCopyDirtyToSys(ExaMigrationPtr migrate)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
PixmapPtr pPixmap = migrate->pPix;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
ExaScreenPriv(pPixmap->drawable.pScreen);
|
|
|
|
ExaPixmapPriv(pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
exaCopyDirty(migrate, &pExaPixmap->validSys, &pExaPixmap->validFB,
|
2012-06-10 07:21:05 -06:00
|
|
|
pExaScr->info->DownloadFromScreen, EXA_PREPARE_SRC,
|
|
|
|
exaWaitSync);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
/**
|
|
|
|
* If the pixmap is currently dirty, this copies at least the dirty area from
|
|
|
|
* the system memory copy to the framebuffer memory copy. Both areas must be
|
|
|
|
* allocated.
|
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaCopyDirtyToFb(ExaMigrationPtr migrate)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
PixmapPtr pPixmap = migrate->pPix;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
ExaScreenPriv(pPixmap->drawable.pScreen);
|
|
|
|
ExaPixmapPriv(pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
exaCopyDirty(migrate, &pExaPixmap->validFB, &pExaPixmap->validSys,
|
2012-06-10 07:21:05 -06:00
|
|
|
pExaScr->info->UploadToScreen, EXA_PREPARE_DEST, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates a framebuffer copy of the pixmap if necessary, and then copies
|
|
|
|
* any necessary pixmap data into the framebuffer copy and points the pixmap at
|
|
|
|
* it.
|
|
|
|
*
|
|
|
|
* Note that when first allocated, a pixmap will have FALSE dirty flag.
|
|
|
|
* This is intentional because pixmap data starts out undefined. So if we move
|
|
|
|
* it in due to the first operation against it being accelerated, it will have
|
|
|
|
* undefined framebuffer contents that we didn't have to upload. If we do
|
|
|
|
* moveouts (and moveins) after the first movein, then we will only have to copy
|
|
|
|
* back and forth if the pixmap was written to after the last synchronization of
|
|
|
|
* the two copies. Then, at exaPixmapSave (when the framebuffer copy goes away)
|
|
|
|
* we mark the pixmap dirty, so that the next exaMoveInPixmap will actually move
|
|
|
|
* all the data, since it's almost surely all valid now.
|
|
|
|
*/
|
2008-11-02 08:26:08 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaDoMoveInPixmap(ExaMigrationPtr migrate)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
PixmapPtr pPixmap = migrate->pPix;
|
|
|
|
ScreenPtr pScreen = pPixmap->drawable.pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
ExaScreenPriv(pScreen);
|
|
|
|
ExaPixmapPriv(pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* If we're VT-switched away, no touching card memory allowed. */
|
|
|
|
if (pExaScr->swappedOut)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* If we're not allowed to move, then fail. */
|
|
|
|
if (exaPixmapIsPinned(pPixmap))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Don't migrate in pixmaps which are less than 8bpp. This avoids a lot of
|
|
|
|
* fragility in EXA, and <8bpp is probably not used enough any more to care
|
|
|
|
* (at least, not in acceleratd paths).
|
|
|
|
*/
|
|
|
|
if (pPixmap->drawable.bitsPerPixel < 8)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (pExaPixmap->accel_blocked)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2007-12-13 14:06:02 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pExaPixmap->area == NULL) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pExaPixmap->area =
|
|
|
|
exaOffscreenAlloc(pScreen, pExaPixmap->fb_size,
|
|
|
|
pExaScr->info->pixmapOffsetAlign, FALSE,
|
|
|
|
exaPixmapSave, (pointer) pPixmap);
|
|
|
|
if (pExaPixmap->area == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pExaPixmap->fb_ptr = (CARD8 *) pExaScr->info->memoryBase +
|
|
|
|
pExaPixmap->area->offset;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
exaCopyDirtyToFb(migrate);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (exaPixmapHasGpuCopy(pPixmap))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DBG_MIGRATE(("-> %p (0x%x) (%dx%d) (%c)\n", pPixmap,
|
|
|
|
(ExaGetPixmapPriv(pPixmap)->area ?
|
|
|
|
ExaGetPixmapPriv(pPixmap)->area->offset : 0),
|
|
|
|
pPixmap->drawable.width,
|
|
|
|
pPixmap->drawable.height,
|
|
|
|
exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
pExaPixmap->use_gpu_copy = TRUE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pPixmap->devKind = pExaPixmap->fb_pitch;
|
|
|
|
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaMoveInPixmap_classic(PixmapPtr pPixmap)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
static ExaMigrationRec migrate = {.as_dst = FALSE,.as_src = TRUE,
|
|
|
|
.pReg = NULL
|
|
|
|
};
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
migrate.pPix = pPixmap;
|
2012-06-10 07:21:05 -06:00
|
|
|
exaDoMoveInPixmap(&migrate);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/**
|
|
|
|
* Switches the current active location of the pixmap to system memory, copying
|
|
|
|
* updated data out if necessary.
|
|
|
|
*/
|
2008-11-02 08:26:08 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaDoMoveOutPixmap(ExaMigrationPtr migrate)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
PixmapPtr pPixmap = migrate->pPix;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
ExaPixmapPriv(pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (!pExaPixmap->area || exaPixmapIsPinned(pPixmap))
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
exaCopyDirtyToSys(migrate);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (exaPixmapHasGpuCopy(pPixmap)) {
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DBG_MIGRATE(("<- %p (%p) (%dx%d) (%c)\n", pPixmap,
|
|
|
|
(void *) (ExaGetPixmapPriv(pPixmap)->area ?
|
|
|
|
ExaGetPixmapPriv(pPixmap)->area->offset : 0),
|
|
|
|
pPixmap->drawable.width,
|
|
|
|
pPixmap->drawable.height,
|
|
|
|
exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pExaPixmap->use_gpu_copy = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pPixmap->devKind = pExaPixmap->sys_pitch;
|
|
|
|
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaMoveOutPixmap_classic(PixmapPtr pPixmap)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
static ExaMigrationRec migrate = {.as_dst = FALSE,.as_src = TRUE,
|
|
|
|
.pReg = NULL
|
|
|
|
};
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
migrate.pPix = pPixmap;
|
2012-06-10 07:21:05 -06:00
|
|
|
exaDoMoveOutPixmap(&migrate);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies out important pixmap data and removes references to framebuffer area.
|
|
|
|
* Called when the memory manager decides it's time to kick the pixmap out of
|
|
|
|
* framebuffer entirely.
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaPixmapSave(ScreenPtr pScreen, ExaOffscreenArea * area)
|
2008-11-02 08:26:08 -07:00
|
|
|
{
|
|
|
|
PixmapPtr pPixmap = area->privData;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
ExaPixmapPriv(pPixmap);
|
|
|
|
|
|
|
|
exaMoveOutPixmap(pPixmap);
|
|
|
|
|
|
|
|
pExaPixmap->fb_ptr = NULL;
|
|
|
|
pExaPixmap->area = NULL;
|
|
|
|
|
|
|
|
/* Mark all FB bits as invalid, so all valid system bits get copied to FB
|
|
|
|
* next time */
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionEmpty(&pExaPixmap->validFB);
|
2008-11-02 08:26:08 -07:00
|
|
|
}
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
/**
|
|
|
|
* For the "greedy" migration scheme, pushes the pixmap toward being located in
|
|
|
|
* framebuffer memory.
|
|
|
|
*/
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaMigrateTowardFb(ExaMigrationPtr migrate)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
PixmapPtr pPixmap = migrate->pPix;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
ExaPixmapPriv(pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pExaPixmap->score == EXA_PIXMAP_SCORE_PINNED) {
|
2012-06-10 07:21:05 -06:00
|
|
|
DBG_MIGRATE(("UseScreen: not migrating pinned pixmap %p\n",
|
|
|
|
(pointer) pPixmap));
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_MIGRATE(("UseScreen %p score %d\n",
|
2012-06-10 07:21:05 -06:00
|
|
|
(pointer) pPixmap, pExaPixmap->score));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pExaPixmap->score == EXA_PIXMAP_SCORE_INIT) {
|
2012-06-10 07:21:05 -06:00
|
|
|
exaDoMoveInPixmap(migrate);
|
|
|
|
pExaPixmap->score = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pExaPixmap->score < EXA_PIXMAP_SCORE_MAX)
|
2012-06-10 07:21:05 -06:00
|
|
|
pExaPixmap->score++;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pExaPixmap->score >= EXA_PIXMAP_SCORE_MOVE_IN &&
|
2012-06-10 07:21:05 -06:00
|
|
|
!exaPixmapHasGpuCopy(pPixmap)) {
|
|
|
|
exaDoMoveInPixmap(migrate);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (exaPixmapHasGpuCopy(pPixmap)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
exaCopyDirtyToFb(migrate);
|
|
|
|
ExaOffscreenMarkUsed(pPixmap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
exaCopyDirtyToSys(migrate);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For the "greedy" migration scheme, pushes the pixmap toward being located in
|
|
|
|
* system memory.
|
|
|
|
*/
|
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaMigrateTowardSys(ExaMigrationPtr migrate)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2008-11-02 08:26:08 -07:00
|
|
|
PixmapPtr pPixmap = migrate->pPix;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
ExaPixmapPriv(pPixmap);
|
|
|
|
|
|
|
|
DBG_MIGRATE(("UseMem: %p score %d\n", (pointer) pPixmap,
|
|
|
|
pExaPixmap->score));
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pExaPixmap->score == EXA_PIXMAP_SCORE_PINNED)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pExaPixmap->score == EXA_PIXMAP_SCORE_INIT)
|
2012-06-10 07:21:05 -06:00
|
|
|
pExaPixmap->score = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pExaPixmap->score > EXA_PIXMAP_SCORE_MIN)
|
2012-06-10 07:21:05 -06:00
|
|
|
pExaPixmap->score--;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (pExaPixmap->score <= EXA_PIXMAP_SCORE_MOVE_OUT && pExaPixmap->area)
|
2012-06-10 07:21:05 -06:00
|
|
|
exaDoMoveOutPixmap(migrate);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (exaPixmapHasGpuCopy(pPixmap)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
exaCopyDirtyToFb(migrate);
|
|
|
|
ExaOffscreenMarkUsed(pPixmap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
exaCopyDirtyToSys(migrate);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the pixmap has both a framebuffer and system memory copy, this function
|
|
|
|
* asserts that both of them are the same.
|
|
|
|
*/
|
2007-11-24 10:55:21 -07:00
|
|
|
static Bool
|
2012-06-10 07:21:05 -06:00
|
|
|
exaAssertNotDirty(PixmapPtr pPixmap)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
ExaPixmapPriv(pPixmap);
|
2006-11-26 11:13:41 -07:00
|
|
|
CARD8 *dst, *src;
|
2008-11-02 08:26:08 -07:00
|
|
|
RegionRec ValidReg;
|
2010-07-27 13:02:24 -06:00
|
|
|
int dst_pitch, src_pitch, cpp, y, nbox, save_pitch;
|
2008-11-02 08:26:08 -07:00
|
|
|
BoxPtr pBox;
|
2010-07-27 13:02:24 -06:00
|
|
|
Bool ret = TRUE, save_use_gpu_copy;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2008-11-02 08:26:08 -07:00
|
|
|
if (exaPixmapIsPinned(pPixmap) || pExaPixmap->area == NULL)
|
2012-06-10 07:21:05 -06:00
|
|
|
return ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionNull(&ValidReg);
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionIntersect(&ValidReg, &pExaPixmap->validFB, &pExaPixmap->validSys);
|
2010-12-05 08:36:02 -07:00
|
|
|
nbox = RegionNumRects(&ValidReg);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
|
|
|
if (!nbox)
|
2012-06-10 07:21:05 -06:00
|
|
|
goto out;
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
pBox = RegionRects(&ValidReg);
|
2008-11-02 08:26:08 -07:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
dst_pitch = pExaPixmap->sys_pitch;
|
|
|
|
src_pitch = pExaPixmap->fb_pitch;
|
2007-11-24 10:55:21 -07:00
|
|
|
cpp = pPixmap->drawable.bitsPerPixel / 8;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
save_use_gpu_copy = pExaPixmap->use_gpu_copy;
|
|
|
|
save_pitch = pPixmap->devKind;
|
|
|
|
pExaPixmap->use_gpu_copy = TRUE;
|
|
|
|
pPixmap->devKind = pExaPixmap->fb_pitch;
|
|
|
|
|
|
|
|
if (!ExaDoPrepareAccess(pPixmap, EXA_PREPARE_SRC))
|
2012-06-10 07:21:05 -06:00
|
|
|
goto skip;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
while (nbox--) {
|
2012-06-10 07:21:05 -06:00
|
|
|
int rowbytes;
|
|
|
|
|
|
|
|
pBox->x1 = max(pBox->x1, 0);
|
|
|
|
pBox->y1 = max(pBox->y1, 0);
|
|
|
|
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 =
|
|
|
|
(CARD8 *) pPixmap->devPrivate.ptr + pBox->y1 * src_pitch +
|
|
|
|
pBox->x1 * cpp;
|
|
|
|
dst = pExaPixmap->sys_ptr + pBox->y1 * dst_pitch + pBox->x1 * cpp;
|
|
|
|
|
|
|
|
for (y = pBox->y1; y < pBox->y2;
|
|
|
|
y++, src += src_pitch, dst += dst_pitch) {
|
|
|
|
if (memcmp(dst, src, rowbytes) != 0) {
|
|
|
|
ret = FALSE;
|
|
|
|
exaPixmapDirty(pPixmap, pBox->x1, pBox->y1, pBox->x2, pBox->y2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
skip:
|
2006-11-26 11:13:41 -07:00
|
|
|
exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
|
2007-11-24 10:55:21 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
pExaPixmap->use_gpu_copy = save_use_gpu_copy;
|
|
|
|
pPixmap->devKind = save_pitch;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
out:
|
2010-12-05 08:36:02 -07:00
|
|
|
RegionUninit(&ValidReg);
|
2007-11-24 10:55:21 -07:00
|
|
|
return ret;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs migration of the pixmaps according to the operation information
|
|
|
|
* provided in pixmaps and can_accel and the migration scheme chosen in the
|
|
|
|
* config file.
|
|
|
|
*/
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
exaDoMigration_classic(ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
ScreenPtr pScreen = pixmaps[0].pPix->drawable.pScreen;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
ExaScreenPriv(pScreen);
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
/* If this debugging flag is set, check each pixmap for whether it is marked
|
|
|
|
* as clean, and if so, actually check if that's the case. This should help
|
|
|
|
* catch issues with failing to mark a drawable as dirty. While it will
|
|
|
|
* catch them late (after the operation happened), it at least explains what
|
|
|
|
* went wrong, and instrumenting the code to find what operation happened
|
|
|
|
* to the pixmap last shouldn't be hard.
|
|
|
|
*/
|
|
|
|
if (pExaScr->checkDirtyCorrectness) {
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
if (!exaPixmapIsDirty(pixmaps[i].pPix) &&
|
|
|
|
!exaAssertNotDirty(pixmaps[i].pPix))
|
|
|
|
ErrorF("%s: Pixmap %d dirty but not marked as such!\n",
|
|
|
|
__func__, i);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
/* If anything is pinned in system memory, we won't be able to
|
|
|
|
* accelerate.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (exaPixmapIsPinned(pixmaps[i].pPix) &&
|
|
|
|
!exaPixmapHasGpuCopy(pixmaps[i].pPix)) {
|
|
|
|
EXA_FALLBACK(("Pixmap %p (%dx%d) pinned in sys\n", pixmaps[i].pPix,
|
|
|
|
pixmaps[i].pPix->drawable.width,
|
|
|
|
pixmaps[i].pPix->drawable.height));
|
|
|
|
can_accel = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pExaScr->migration == ExaMigrationSmart) {
|
2012-06-10 07:21:05 -06:00
|
|
|
/* If we've got something as a destination that we shouldn't cause to
|
|
|
|
* become newly dirtied, take the unaccelerated route.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
if (pixmaps[i].as_dst && !exaPixmapShouldBeInFB(pixmaps[i].pPix) &&
|
|
|
|
!exaPixmapIsDirty(pixmaps[i].pPix)) {
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
if (!exaPixmapIsDirty(pixmaps[i].pPix))
|
|
|
|
exaDoMoveOutPixmap(pixmaps + i);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we aren't going to accelerate, then we migrate everybody toward
|
|
|
|
* system memory, and kick out if it's free.
|
|
|
|
*/
|
|
|
|
if (!can_accel) {
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
exaMigrateTowardSys(pixmaps + i);
|
|
|
|
if (!exaPixmapIsDirty(pixmaps[i].pPix))
|
|
|
|
exaDoMoveOutPixmap(pixmaps + i);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally, the acceleration path. Move them all in. */
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
exaMigrateTowardFb(pixmaps + i);
|
|
|
|
exaDoMoveInPixmap(pixmaps + i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pExaScr->migration == ExaMigrationGreedy) {
|
|
|
|
/* If we can't accelerate, either because the driver can't or because one of
|
|
|
|
* the pixmaps is pinned in system memory, then we migrate everybody toward
|
|
|
|
* system memory.
|
|
|
|
*
|
|
|
|
* We also migrate toward system if all pixmaps involved are currently in
|
|
|
|
* system memory -- this can mitigate thrashing when there are significantly
|
|
|
|
* more pixmaps active than would fit in memory.
|
|
|
|
*
|
|
|
|
* If not, then we migrate toward FB so that hopefully acceleration can
|
|
|
|
* happen.
|
|
|
|
*/
|
|
|
|
if (!can_accel) {
|
|
|
|
for (i = 0; i < npixmaps; i++)
|
|
|
|
exaMigrateTowardSys(pixmaps + i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
if (exaPixmapHasGpuCopy(pixmaps[i].pPix)) {
|
|
|
|
/* Found one in FB, so move all to FB. */
|
|
|
|
for (j = 0; j < npixmaps; j++)
|
|
|
|
exaMigrateTowardFb(pixmaps + i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Nobody's in FB, so move all away from FB. */
|
|
|
|
for (i = 0; i < npixmaps; i++)
|
|
|
|
exaMigrateTowardSys(pixmaps + i);
|
|
|
|
}
|
|
|
|
else if (pExaScr->migration == ExaMigrationAlways) {
|
|
|
|
/* Always move the pixmaps out if we can't accelerate. If we can
|
|
|
|
* accelerate, try to move them all in. If that fails, then move them
|
|
|
|
* back out.
|
|
|
|
*/
|
|
|
|
if (!can_accel) {
|
|
|
|
for (i = 0; i < npixmaps; i++)
|
|
|
|
exaDoMoveOutPixmap(pixmaps + i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now, try to move them all into FB */
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
exaDoMoveInPixmap(pixmaps + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we couldn't fit everything in, abort */
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
if (!exaPixmapHasGpuCopy(pixmaps[i].pPix)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Yay, everything has a gpu copy, mark memory as used */
|
|
|
|
for (i = 0; i < npixmaps; i++) {
|
|
|
|
ExaOffscreenMarkUsed(pixmaps[i].pPix);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
void
|
|
|
|
exaPrepareAccessReg_classic(PixmapPtr pPixmap, int index, RegionPtr pReg)
|
|
|
|
{
|
|
|
|
ExaMigrationRec pixmaps[1];
|
|
|
|
|
|
|
|
if (index == EXA_PREPARE_DEST || index == EXA_PREPARE_AUX_DEST) {
|
2012-06-10 07:21:05 -06:00
|
|
|
pixmaps[0].as_dst = TRUE;
|
|
|
|
pixmaps[0].as_src = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pixmaps[0].as_dst = FALSE;
|
|
|
|
pixmaps[0].as_src = TRUE;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
pixmaps[0].pPix = pPixmap;
|
|
|
|
pixmaps[0].pReg = pReg;
|
|
|
|
|
|
|
|
exaDoMigration(pixmaps, 1, FALSE);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
(void) ExaDoPrepareAccess(pPixmap, index);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|