summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2004-01-08 08:16:24 +0000
committerEric Anholt <anholt@freebsd.org>2004-01-08 08:16:24 +0000
commitb27729ec88f5d4153a0debfe2347bbed022329ba (patch)
tree8594960e3f2f652000d9202ea6648f72a2452162
parentd640cf4cb4e031a0e93dfd5955405847fe4475c0 (diff)
- Add a new UploadToScratch kaa hook for putting the data for a single
pixmap into temporary offscreen storage. Subsequent UploadToScratch may clobber the data of previous ones. This allows hardware acceleration of composite operations on glyphs. - Add a new UploadToScreen kaa hook for doing the actual moving of data to framebuffer. This would allow us to do things like hostdata blits or memcpy to agp and then blit. - Add an UploadToScreen on ATI which is just memcpy, but which will be replaced with a hostdata blit soon. - Add UploadToScratch on ATI and reserve 64k of scratch space. This provided a 3x speedup of rgb24text on my Radeon.
-rw-r--r--hw/kdrive/ati/ati.c17
-rw-r--r--hw/kdrive/ati/ati.h3
-rw-r--r--hw/kdrive/ati/ati_draw.c54
-rw-r--r--hw/kdrive/src/kaa.c12
-rw-r--r--hw/kdrive/src/kaapict.c15
-rw-r--r--hw/kdrive/src/kdrive.h6
6 files changed, 99 insertions, 8 deletions
diff --git a/hw/kdrive/ati/ati.c b/hw/kdrive/ati/ati.c
index bdd3c4941..1e6fa18b8 100644
--- a/hw/kdrive/ati/ati.c
+++ b/hw/kdrive/ati/ati.c
@@ -269,9 +269,7 @@ ATIScreenInit(KdScreenInfo *screen)
if (atic->use_fbdev) {
success = fbdevScreenInitialize(screen,
&atis->backend_priv.fbdev);
- screen->memory_size = min(atic->backend_priv.fbdev.fix.smem_len,
- 8192 * screen->fb[0].byteStride);
- /*screen->memory_size = atic->backend_priv.fbdev.fix.smem_len;*/
+ screen->memory_size = atic->backend_priv.fbdev.fix.smem_len;
screen->off_screen_base =
atic->backend_priv.fbdev.var.yres_virtual *
screen->fb[0].byteStride;
@@ -285,12 +283,25 @@ ATIScreenInit(KdScreenInfo *screen)
&atis->backend_priv.vesa);
}
#endif
+
if (!success) {
screen->driver = NULL;
xfree(atis);
return FALSE;
}
+ /* Reserve a scratch area. It'll be used for storing glyph data during
+ * Composite operations, because glyphs aren't in real pixmaps and thus
+ * can't be migrated.
+ */
+ atis->scratch_size = 65536; /* big enough for 128x128@32bpp */
+ if (screen->off_screen_base + atis->scratch_size > screen->memory_size)
+ atis->scratch_size = 0;
+ else {
+ atis->scratch_offset = screen->off_screen_base;
+ screen->off_screen_base += atis->scratch_size;
+ }
+
return TRUE;
}
diff --git a/hw/kdrive/ati/ati.h b/hw/kdrive/ati/ati.h
index cacc264dd..5d10d9253 100644
--- a/hw/kdrive/ati/ati.h
+++ b/hw/kdrive/ati/ati.h
@@ -147,6 +147,9 @@ typedef struct _ATIScreenInfo {
Bool using_dri;
Bool using_dma;
+ int scratch_offset;
+ int scratch_size;
+
#ifdef USE_DRI
drmSize registerSize;
drmHandle registerHandle;
diff --git a/hw/kdrive/ati/ati_draw.c b/hw/kdrive/ati/ati_draw.c
index 1e2879443..250d1b337 100644
--- a/hw/kdrive/ati/ati_draw.c
+++ b/hw/kdrive/ati/ati_draw.c
@@ -378,6 +378,53 @@ RadeonSwitchTo3D(void)
ADVANCE_RING();
}
+static Bool
+ATIUploadToScreen(PixmapPtr pDst, char *src, int src_pitch)
+{
+ int i;
+ char *dst;
+ int dst_pitch;
+ int bytes;
+
+ dst = pDst->devPrivate.ptr;
+ dst_pitch = pDst->devKind;
+ bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
+
+ KdCheckSync(pDst->drawable.pScreen);
+
+ for (i = 0; i < pDst->drawable.height; i++) {
+ memcpy(dst, src, bytes);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+
+ return TRUE;
+}
+
+
+static Bool
+ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
+{
+ KdScreenPriv(pSrc->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ int dst_pitch;
+
+ dst_pitch = (pSrc->drawable.width * pSrc->drawable.bitsPerPixel / 8 +
+ atis->kaa.offscreenPitch - 1) & ~(atis->kaa.offscreenPitch - 1);
+
+ if (dst_pitch * pSrc->drawable.height > atis->scratch_size)
+ ATI_FALLBACK(("Pixmap too large for scratch (%d,%d)\n",
+ pSrc->drawable.width, pSrc->drawable.height));
+
+ memcpy(pDst, pSrc, sizeof(*pDst));
+ pDst->devKind = dst_pitch;
+ pDst->devPrivate.ptr = atis->scratch_offset +
+ pScreenPriv->screen->memory_base;
+
+ return ATIUploadToScreen(pDst, pSrc->devPrivate.ptr, pSrc->devKind);
+}
+
+
#endif /* USE_DRI */
static Bool
@@ -392,7 +439,7 @@ R128GetDatatypePict(CARD32 format, CARD32 *type)
return TRUE;
}
- ErrorF ("Unsupported format: %x\n", format);
+ ATI_FALLBACK(("Unsupported format: %x\n", format));
return FALSE;
}
@@ -420,7 +467,7 @@ ATIGetDatatypeBpp(int bpp, CARD32 *type)
*type = R128_DATATYPE_ARGB_8888;
return TRUE;
default:
- ErrorF("Unsupported bpp: %x\n", bpp);
+ ATI_FALLBACK(("Unsupported bpp: %x\n", bpp));
return FALSE;
}
}
@@ -496,6 +543,9 @@ ATIDrawInit(ScreenPtr pScreen)
atis->kaa.DoneBlend = R128DoneBlendMMIO;
}
}
+ atis->kaa.UploadToScreen = ATIUploadToScreen;
+ if (atis->scratch_size != 0)
+ atis->kaa.UploadToScratch = ATIUploadToScratch;
atis->kaa.DoneSolid = ATIDoneSolid;
atis->kaa.DoneCopy = ATIDoneCopy;
atis->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c
index a13e258aa..5e67368a8 100644
--- a/hw/kdrive/src/kaa.c
+++ b/hw/kdrive/src/kaa.c
@@ -131,12 +131,12 @@ kaaPixmapAllocArea (PixmapPtr pPixmap)
static void
kaaMoveInPixmap (PixmapPtr pPixmap)
{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ KaaScreenPriv (pScreen);
int dst_pitch, src_pitch, bytes;
unsigned char *dst, *src;
int i;
- KdCheckSync (pPixmap->drawable.pScreen);
-
DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n",
pPixmap->drawable.id,
KaaGetPixmapPriv(pPixmap)->area ?
@@ -150,11 +150,19 @@ kaaMoveInPixmap (PixmapPtr pPixmap)
if (!kaaPixmapAllocArea (pPixmap))
return;
+ if (pKaaScr->info->UploadToScreen)
+ {
+ if (pKaaScr->info->UploadToScreen(pPixmap, src, src_pitch))
+ return;
+ }
+
dst = pPixmap->devPrivate.ptr;
dst_pitch = pPixmap->devKind;
bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
+ KdCheckSync (pPixmap->drawable.pScreen);
+
i = pPixmap->drawable.height;
while (i--) {
memcpy (dst, src, bytes);
diff --git a/hw/kdrive/src/kaapict.c b/hw/kdrive/src/kaapict.c
index 88bebbf91..d8badbd08 100644
--- a/hw/kdrive/src/kaapict.c
+++ b/hw/kdrive/src/kaapict.c
@@ -319,6 +319,7 @@ kaaTryDriverBlend(CARD8 op,
int nbox;
int src_off_x, src_off_y, dst_off_x, dst_off_y;
PixmapPtr pSrcPix, pDstPix;
+ struct _Pixmap srcScratch;
xDst += pDst->pDrawable->x;
yDst += pDst->pDrawable->y;
@@ -339,7 +340,19 @@ kaaTryDriverBlend(CARD8 op,
pSrcPix = kaaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
pDstPix = kaaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
- if (!pSrcPix || !pDstPix) {
+
+ if (!pDstPix) {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 0;
+ }
+
+ if (!pSrcPix && pKaaScr->info->UploadToScratch) {
+ if ((*pKaaScr->info->UploadToScratch) ((PixmapPtr) pSrc->pDrawable,
+ &srcScratch))
+ pSrcPix = &srcScratch;
+ }
+
+ if (!pSrcPix) {
REGION_UNINIT(pDst->pDrawable->pScreen, &region);
return 0;
}
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index bee6393b7..bb9bc238d 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -363,6 +363,12 @@ typedef struct _KaaScreenInfo {
int width,
int height);
void (*DoneComposite) (void);
+
+ Bool (*UploadToScreen) (PixmapPtr pDst,
+ char *src,
+ int src_pitch);
+ Bool (*UploadToScratch) (PixmapPtr pSrc,
+ PixmapPtr pDst);
} KaaScreenInfoRec, *KaaScreenInfoPtr;
#define KAA_OFFSCREEN_PIXMAPS (1 << 0)