[xserver-commit] xserver/hw/kdrive/ati ati.c,1.8,1.9 ati.h,1.4,1.5 ati_draw.c,1.9,1.10

Eric Anholt xserver-commit@pdx.freedesktop.org
Thu, 08 Jan 2004 00:16:26 -0800


Committed by: anholt

Update of /cvs/xserver/xserver/hw/kdrive/ati
In directory pdx:/home/anholt/xserver/hw/kdrive/ati

Modified Files:
	ati.c ati.h ati_draw.c 
Log Message:
- 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.


Index: ati.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ati.c	29 Dec 2003 06:24:01 -0000	1.8
+++ ati.c	8 Jan 2004 08:16:24 -0000	1.9
@@ -269,9 +269,7 @@
 	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 @@
 		    &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;
 }
 

Index: ati.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ati.h	29 Dec 2003 06:24:01 -0000	1.4
+++ ati.h	8 Jan 2004 08:16:24 -0000	1.5
@@ -147,6 +147,9 @@
 	Bool using_dri;
 	Bool using_dma;
 
+	int scratch_offset;
+	int scratch_size;
+
 #ifdef USE_DRI
 	drmSize         registerSize;
 	drmHandle       registerHandle;

Index: ati_draw.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ati_draw.c	4 Jan 2004 20:47:30 -0000	1.9
+++ ati_draw.c	8 Jan 2004 08:16:24 -0000	1.10
@@ -378,6 +378,53 @@
 	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 @@
 		return TRUE;
 	}
 
-	ErrorF ("Unsupported format: %x\n", format);
+	ATI_FALLBACK(("Unsupported format: %x\n", format));
 
 	return FALSE;
 }
@@ -420,7 +467,7 @@
 		*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 @@
 			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;