From 77f98717d825162da106c6898cdbcbdf5c984ae6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 22 Aug 2009 21:16:25 +1000 Subject: exa/cs: add DFS from GTT optimisation This uses the new libdrm busy interface, once I had this in place I added a error if this happened and it does on my desktop here, so may as well add the optimisation that used to be in my old KMS tree. Signed-off-by: Dave Airlie --- src/radeon_exa_funcs.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/radeon_exa_funcs.c b/src/radeon_exa_funcs.c index e48317f5..f937c4e3 100644 --- a/src/radeon_exa_funcs.c +++ b/src/radeon_exa_funcs.c @@ -506,6 +506,33 @@ out: return r; } +static Bool +RADEONDownloadFromScreenGTT(PixmapPtr pSrc, int x, int y, int w, + int h, char *dst, int dst_pitch) +{ + struct radeon_exa_pixmap_priv *driver_priv; + int src_pitch = exaGetPixmapPitch(pSrc); + int bpp = pSrc->drawable.bitsPerPixel; + int src_offset; + int r; + + driver_priv = exaGetPixmapDriverPrivate(pSrc); + r = radeon_bo_map(driver_priv->bo, 0); + if (r) + return FALSE; + + src_offset = (x * bpp / 8) + (y * src_pitch); + w *= bpp / 8; + + while (h--) { + memcpy(dst, driver_priv->bo->ptr + src_offset, w); + src_offset += src_pitch; + dst += dst_pitch; + } + radeon_bo_unmap(driver_priv->bo); + return TRUE; +} + static Bool RADEONDownloadFromScreenCS(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch) @@ -519,11 +546,19 @@ RADEONDownloadFromScreenCS(PixmapPtr pSrc, int x, int y, int w, unsigned bpp = pSrc->drawable.bitsPerPixel; uint32_t scratch_pitch = (w * bpp / 8 + 63) & ~63; Bool r; + uint32_t src_domain; + int busy; if (bpp < 8) return FALSE; driver_priv = exaGetPixmapDriverPrivate(pSrc); + + busy = radeon_bo_is_busy(driver_priv->bo, &src_domain); + + if (src_domain == RADEON_GEM_DOMAIN_GTT) + return RADEONDownloadFromScreenGTT(pSrc, x, y, w, h, + dst, dst_pitch); size = scratch_pitch * h; scratch = radeon_bo_open(info->bufmgr, 0, size, 0, RADEON_GEM_DOMAIN_GTT, 0); -- cgit v1.2.3