summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellström <thomas@shipmail.org>2008-10-29 10:57:32 +0000
committerThomas Hellström <thomas@shipmail.org>2008-10-29 10:57:32 +0000
commit9e3268b9fa61c9f187c4f69fa8be9806cb67fa47 (patch)
tree5f486d51690c2b85705683d5148bd3d12e83a8e2
parente8349f9a6d820b31f13f4bff9517526dd8948ce4 (diff)
Add uploadtoscrach support using a temporary buffer
-rw-r--r--src/via_accel.c85
-rw-r--r--src/via_driver.h1
2 files changed, 63 insertions, 23 deletions
diff --git a/src/via_accel.c b/src/via_accel.c
index 63a8399..0fd82ae 100644
--- a/src/via_accel.c
+++ b/src/via_accel.c
@@ -652,6 +652,23 @@ viaExaDoneSolidCopy(PixmapPtr pPixmap)
}
static void
+viaFreeScratchBuffers(VIAPtr pVia)
+{
+ struct _ViaOffscreenBuffer *entry;
+ struct _WSDriListHead *list;
+ struct _WSDriListHead *prev;
+
+ WSDRILISTFOREACHPREVSAFE(list, prev, &pVia->offscreen) {
+ entry = WSDRILISTENTRY(list, struct _ViaOffscreenBuffer, head);
+ if (entry->scratch) {
+ WSDRILISTDEL(list);
+ driBOUnReference(entry->buf);
+ free(entry);
+ }
+ }
+}
+
+static void
viaExaDoneComposite(PixmapPtr pPixmap)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
@@ -660,6 +677,8 @@ viaExaDoneComposite(PixmapPtr pPixmap)
cb->inComposite = FALSE;
FLUSH_RING;
+
+ viaFreeScratchBuffers(pVia);
}
@@ -1023,7 +1042,6 @@ viaExaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
#endif
#endif
-#if 0
static Bool
viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
@@ -1033,48 +1051,64 @@ viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
char *src, *dst;
unsigned w, wBytes, srcPitch, h;
CARD32 dstPitch;
- size = dstPitch * h;
+ struct _ViaOffscreenBuffer *entry;
+ int ret;
+ unsigned size;
- if (!pVia->scratchAddr)
- return FALSE;
+ entry = malloc(sizeof(*entry));
+ if (!entry)
+ return FALSE;
+
+ ret = driGenBuffers(pVia->mainPool, "Scratch buffer", 1,
+ &entry->buf, 0,
+ VIA_BO_FLAG_MEM_AGP |
+ DRM_BO_FLAG_MEM_VRAM |
+ DRM_BO_FLAG_READ, 0);
+ if (ret)
+ goto out_err0;
- *pDst = *pSrc;
w = pSrc->drawable.width;
h = pSrc->drawable.height;
wBytes = (w * pSrc->drawable.bitsPerPixel + 7) >> 3;
dstPitch = (wBytes + 31) & ~31;
-
-
+ size = dstPitch * h;
+ ret = driBOData(entry->buf, size, NULL, NULL, 0);
+ if (ret)
+ goto out_err1;
- if (dstPitch * h > pVia->exaScratchSize * 1024) {
- ErrorF("EXA UploadToScratch Failed %u %u %u %u\n",
- dstPitch, h, dstPitch * h, pVia->exaScratchSize * 1024);
- return FALSE;
- }
+ dst = driBOMap(entry->buf, WS_DRI_MAP_WRITE);
+ if (dst == NULL)
+ goto out_err1;
+ *pDst = *pSrc;
+
pDst->devKind = dstPitch;
- pDst->devPrivate.ptr = dst = pVia->scratchAddr;
+ pDst->devPrivate.ptr = dst;
src = pSrc->devPrivate.ptr;
srcPitch = exaGetPixmapPitch(pSrc);
- /*
- * Copying to AGP needs not be HW accelerated.
- * If scratch is in FB, we are without DRI and HW accel.
- */
-
- viaAccelSync(pScrn);
-
while (h--) {
memcpy(dst, src, wBytes);
dst += dstPitch;
src += srcPitch;
}
+ (void) driBOUnmap(entry->buf);
+ entry->size = size;
+ entry->virtual = pDst->devPrivate.ptr;
+ entry->scratch = TRUE;
+
+ WSDRILISTADDTAIL(&entry->head, &pVia->offscreen);
+
return TRUE;
-}
-#endif
+ out_err1:
+ driBOUnReference(entry->buf);
+ out_err0:
+ free(entry);
+ return FALSE;
+}
static Bool
viaExaCheckComposite(int op, PicturePtr pSrcPicture,
@@ -1382,7 +1416,7 @@ viaInitExa(ScreenPtr pScreen)
#endif /* XF86DRI */
- pExa->UploadToScratch = NULL; /* viaExaUploadToScratch; */
+ pExa->UploadToScratch = viaExaUploadToScratch;
if (!pVia->noComposite) {
pExa->CheckComposite = viaExaCheckComposite;
@@ -1468,6 +1502,8 @@ viaInitAccel(ScreenPtr pScreen)
}
driBOUnmap(pVia->exaMem.buf);
pVia->exaMem.size = driBOSize(pVia->exaMem.buf);
+ pVia->exaMem.scratch = FALSE;
+ pVia->front.scratch = FALSE;
WSDRIINITLISTHEAD(&pVia->offscreen);
WSDRILISTADDTAIL(&pVia->front.head, &pVia->offscreen);
@@ -1536,6 +1572,9 @@ viaExitAccel(ScreenPtr pScreen)
xfree(pVia->exaDriverPtr);
pVia->exaDriverPtr = NULL;
viaTearDownCBuffer(&pVia->cb);
+ viaFreeScratchBuffers(pVia);
+ WSDRILISTDELINIT(&pVia->front.head);
+ WSDRILISTDELINIT(&pVia->exaMem.head);
driDeleteBuffers(1, &pVia->exaMem.buf);
return;
}
diff --git a/src/via_driver.h b/src/via_driver.h
index 43e6d5d..7399909 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -236,6 +236,7 @@ struct _ViaOffscreenBuffer {
struct _DriBufferObject *buf;
char *virtual;
unsigned long size;
+ Bool scratch;
};