Commit b27729ec authored by Eric Anholt's avatar Eric Anholt

- 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.
parent d640cf4c
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment