- 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.
This commit is contained in:
Eric Anholt 2004-01-08 08:16:24 +00:00
parent d640cf4cb4
commit b27729ec88
6 changed files with 99 additions and 8 deletions

View File

@ -269,9 +269,7 @@ ATIScreenInit(KdScreenInfo *screen)
if (atic->use_fbdev) { if (atic->use_fbdev) {
success = fbdevScreenInitialize(screen, success = fbdevScreenInitialize(screen,
&atis->backend_priv.fbdev); &atis->backend_priv.fbdev);
screen->memory_size = min(atic->backend_priv.fbdev.fix.smem_len, screen->memory_size = atic->backend_priv.fbdev.fix.smem_len;
8192 * screen->fb[0].byteStride);
/*screen->memory_size = atic->backend_priv.fbdev.fix.smem_len;*/
screen->off_screen_base = screen->off_screen_base =
atic->backend_priv.fbdev.var.yres_virtual * atic->backend_priv.fbdev.var.yres_virtual *
screen->fb[0].byteStride; screen->fb[0].byteStride;
@ -285,12 +283,25 @@ ATIScreenInit(KdScreenInfo *screen)
&atis->backend_priv.vesa); &atis->backend_priv.vesa);
} }
#endif #endif
if (!success) { if (!success) {
screen->driver = NULL; screen->driver = NULL;
xfree(atis); xfree(atis);
return FALSE; 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; return TRUE;
} }

View File

@ -147,6 +147,9 @@ typedef struct _ATIScreenInfo {
Bool using_dri; Bool using_dri;
Bool using_dma; Bool using_dma;
int scratch_offset;
int scratch_size;
#ifdef USE_DRI #ifdef USE_DRI
drmSize registerSize; drmSize registerSize;
drmHandle registerHandle; drmHandle registerHandle;

View File

@ -378,6 +378,53 @@ RadeonSwitchTo3D(void)
ADVANCE_RING(); 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 */ #endif /* USE_DRI */
static Bool static Bool
@ -392,7 +439,7 @@ R128GetDatatypePict(CARD32 format, CARD32 *type)
return TRUE; return TRUE;
} }
ErrorF ("Unsupported format: %x\n", format); ATI_FALLBACK(("Unsupported format: %x\n", format));
return FALSE; return FALSE;
} }
@ -420,7 +467,7 @@ ATIGetDatatypeBpp(int bpp, CARD32 *type)
*type = R128_DATATYPE_ARGB_8888; *type = R128_DATATYPE_ARGB_8888;
return TRUE; return TRUE;
default: default:
ErrorF("Unsupported bpp: %x\n", bpp); ATI_FALLBACK(("Unsupported bpp: %x\n", bpp));
return FALSE; return FALSE;
} }
} }
@ -496,6 +543,9 @@ ATIDrawInit(ScreenPtr pScreen)
atis->kaa.DoneBlend = R128DoneBlendMMIO; atis->kaa.DoneBlend = R128DoneBlendMMIO;
} }
} }
atis->kaa.UploadToScreen = ATIUploadToScreen;
if (atis->scratch_size != 0)
atis->kaa.UploadToScratch = ATIUploadToScratch;
atis->kaa.DoneSolid = ATIDoneSolid; atis->kaa.DoneSolid = ATIDoneSolid;
atis->kaa.DoneCopy = ATIDoneCopy; atis->kaa.DoneCopy = ATIDoneCopy;
atis->kaa.flags = KAA_OFFSCREEN_PIXMAPS; atis->kaa.flags = KAA_OFFSCREEN_PIXMAPS;

View File

@ -131,12 +131,12 @@ kaaPixmapAllocArea (PixmapPtr pPixmap)
static void static void
kaaMoveInPixmap (PixmapPtr pPixmap) kaaMoveInPixmap (PixmapPtr pPixmap)
{ {
ScreenPtr pScreen = pPixmap->drawable.pScreen;
KaaScreenPriv (pScreen);
int dst_pitch, src_pitch, bytes; int dst_pitch, src_pitch, bytes;
unsigned char *dst, *src; unsigned char *dst, *src;
int i; int i;
KdCheckSync (pPixmap->drawable.pScreen);
DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n", DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n",
pPixmap->drawable.id, pPixmap->drawable.id,
KaaGetPixmapPriv(pPixmap)->area ? KaaGetPixmapPriv(pPixmap)->area ?
@ -150,11 +150,19 @@ kaaMoveInPixmap (PixmapPtr pPixmap)
if (!kaaPixmapAllocArea (pPixmap)) if (!kaaPixmapAllocArea (pPixmap))
return; return;
if (pKaaScr->info->UploadToScreen)
{
if (pKaaScr->info->UploadToScreen(pPixmap, src, src_pitch))
return;
}
dst = pPixmap->devPrivate.ptr; dst = pPixmap->devPrivate.ptr;
dst_pitch = pPixmap->devKind; dst_pitch = pPixmap->devKind;
bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch; bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
KdCheckSync (pPixmap->drawable.pScreen);
i = pPixmap->drawable.height; i = pPixmap->drawable.height;
while (i--) { while (i--) {
memcpy (dst, src, bytes); memcpy (dst, src, bytes);

View File

@ -319,6 +319,7 @@ kaaTryDriverBlend(CARD8 op,
int nbox; int nbox;
int src_off_x, src_off_y, dst_off_x, dst_off_y; int src_off_x, src_off_y, dst_off_x, dst_off_y;
PixmapPtr pSrcPix, pDstPix; PixmapPtr pSrcPix, pDstPix;
struct _Pixmap srcScratch;
xDst += pDst->pDrawable->x; xDst += pDst->pDrawable->x;
yDst += pDst->pDrawable->y; yDst += pDst->pDrawable->y;
@ -339,7 +340,19 @@ kaaTryDriverBlend(CARD8 op,
pSrcPix = kaaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y); pSrcPix = kaaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
pDstPix = kaaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_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); REGION_UNINIT(pDst->pDrawable->pScreen, &region);
return 0; return 0;
} }

View File

@ -363,6 +363,12 @@ typedef struct _KaaScreenInfo {
int width, int width,
int height); int height);
void (*DoneComposite) (void); void (*DoneComposite) (void);
Bool (*UploadToScreen) (PixmapPtr pDst,
char *src,
int src_pitch);
Bool (*UploadToScratch) (PixmapPtr pSrc,
PixmapPtr pDst);
} KaaScreenInfoRec, *KaaScreenInfoPtr; } KaaScreenInfoRec, *KaaScreenInfoPtr;
#define KAA_OFFSCREEN_PIXMAPS (1 << 0) #define KAA_OFFSCREEN_PIXMAPS (1 << 0)