set of patches from the last 3 weeks

"eric anholt" <[email protected]>
Newsgroups gmane.comp.freedesktop.xserver
Message-ID <[email protected]>
Here are a few of the patches I've been working on while I've been here in 
Cuba.  I can't commit them myself because I don't have access to anything 
but email and web -- no cvs, cvsup, ftp, ssh, telnet, etc.  Besides, I'm so 
out of contact that I wouldn't be able to clean up after any mess I made.  
So, I'm hoping someone will pick these up and commit if they look good.

The first is some work on the offscreen memory manager.  The first part of 
it is marking pixmaps as dirty whenever they get written to.  This allows us 
to avoid the read from framebuffer when moving back to main memory.  I think 
I've managed to find all the places the pixmap would get touched, but 
someone should look it over to see if I've made any bad assumptions or 
missed places.  Depending on how fast writing to fb is compared to reading 
from fb, we may want to just throw out !dirty pixmaps in offscreen when 
kaaPixmapUseMemory is called.

The second part is keeping a score of how used each pixmap is.  The existing 
score value was only really useful for keeping track of whether a pixmap 
ought to be in framebuffer or not, not whether it was of more value in 
framebuffer than another pixmap.  So, a new score is also kept that gets 
bumped when a pixmap in memory is used and which is degraded over time.  The 
simple calculation now of what set of pixmaps to throw out when allocating 
is whatever group has the least total score that will let the allocation 
succeed.  I don't know of a good enough way to calculate a good working set 
to decide to fail the allocation, so any time we UseScreen a pixmap that 
should be on screen, we bring it in again if it was in memory.  The numbers 
used for how often the value is degraded and for how much the value is 
degraded are arbitrary and un-tuned, primarily because I don't know of any 
good simulation of a desktop environment that we would want to use to 
measure the effectiveness and overhead.  However, I can say that 
subjectively the server is doing much better since I've added this.

The second is a tarball of a trident driver.  I based it off of the old 
driver from Keith, but used the Xati style and fixed some bugs.  I'm not 
sure what the deal is with the corruption on dx < 0 copies (seen for example 
when dragging a window quickly to the right without xcompmgr, but not in any 
other circumstance as far as I can tell), but things seem to work fine if I 
just have those copies fall back.  The server is quite usable with xcompmgr. 
  I'd still like to get the hardware cursor support in, and maybe the 
Composite accel if it's useful, but it's probably as much as I'm going to do 
with that driver for a while, particularly since I didn't bring the docs 
with me.  The computer got damaged and the keyboard doesn't work, so I've 
been working on the thing remotely.  The tarball also contains the bits I 
was working on for the blade driver but which I haven't tested at all.

Work is progressing on a render test suite.  I'm not using Cairo, because it 
doesn't look like it would let me stress Composite as specifically as I 
would like.  So, I'm just comparing the server's output to expected output I 
calculate using floating point calculations.  My main problem is lack of 
xlib knowledge.  I'm fetching the (0,0) value of a window successfully, it 
looks like, but fetching other pixels isn't working.  If someone could 
forward me some sample xlib code to grab an arbitrary pixel from a window 
(and stuff it in an XRenderColor), that would help me a lot.  I don't have 
xlib manual pages or other documentation, and internet access is really 
expensive.  I've written a few tests despite that, and things seem to be 
going pretty well.  I noticed that the Saturate was being done as a 
fbCombineDisjointOver instead of fbCombineDisjointOverReverse, contrary to 
the spec.  I'm not sure if the unused fbCombineSaturate implementations 
would be useful speed-wise, so the diff just axes them and uses the right 
disjoint op.

At this point I'm stuck on the mask != null composite tests because the 
server usually hangs (no C-A-B, but magic sysrq can save me).  It will also 
hang almost 100% of the time when I open the gnome font preferences window 
or SciTE over the network from the trident box, and I've seen it in a couple 
of other odd situations.  It also happens with Xvesa (at least the SciTE 
issue), which confuses me.  It doesn't appear to be related directly to the 
offscreen work, but rather a side effect of it.  So far I've tried disabling 
the dirty optimization with no change, and enabling offscreen debugging to 
see if there was a problem with the offscreen changes, which didn't complain 
about anything.  However, I can't say for sure that it's not a problem with 
the offscreen stuff.

Also attached is a little fix to the ATI driver to allow R128 to accelerate 
more cases, particularly the 1400x1050x16bpp screen case on my laptop.

Please send all replies or personal communication to [email protected], 
but remember that I probably won't be able to respond for a week, and try to 
be nice because it's expensive to check email.  My lclark.edu box is 
extremely full and I won't find anything in there.

_________________________________________________________________
Click, drag and drop. My MSN is the simple way to design your homepage. 
http://click.atdmt.com/AVE/go/onm00200364ave/direct/01/
xserver-offscreen-4.diff (text/plain, 17.1 KB)
Index: kaa.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kaa.c,v
retrieving revision 1.23
diff -u -r1.23 kaa.c
--- kaa.c	8 Jan 2004 08:16:24 -0000	1.23
+++ kaa.c	19 Feb 2004 22:33:08 -0000
@@ -54,25 +54,36 @@
#define KAA_PIXMAP_SCORE_MOVE_OUT   -10
#define KAA_PIXMAP_SCORE_MIN	    -20

-#define MIN_OFFPIX_SIZE		(4096)
+void
+kaaPixmapDirty (DrawablePtr pDrawable)
+{
+    PixmapPtr pPixmap;
+    KaaPixmapPrivPtr pKaaPixmap;
+
+    if (pDrawable->type == DRAWABLE_WINDOW)
+	pPixmap = (*pDrawable->pScreen->GetWindowPixmap)((WindowPtr) pDrawable);
+    else
+	pPixmap = (PixmapPtr)pDrawable;
+
+    pKaaPixmap = KaaGetPixmapPriv(pPixmap);
+    pKaaPixmap->dirty = TRUE;
+}

static void
kaaPixmapSave (ScreenPtr pScreen, KdOffscreenArea *area)
{
     PixmapPtr pPixmap = area->privData;
-    KaaPixmapPriv(pPixmap);
+    KaaPixmapPriv (pPixmap);
     int dst_pitch, src_pitch, bytes;
     unsigned char *dst, *src;
     int i;

     DBG_MIGRATE (("Save 0x%08x (0x%x) (%dx%d)\n",
		  pPixmap->drawable.id,
-		  KaaGetPixmapPriv(pPixmap)->area ?
-		  KaaGetPixmapPriv(pPixmap)->area->offset : -1,
+		  pKaaPixmap->area ?
+		  pKaaPixmap->area->offset : -1,
		  pPixmap->drawable.width,
		  pPixmap->drawable.height));
-
-    KdCheckSync (pPixmap->drawable.pScreen);

     src_pitch = pPixmap->devKind;
     dst_pitch = pKaaPixmap->devKind;
@@ -84,15 +95,21 @@
     pPixmap->devPrivate.ptr = dst;
     pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
     pKaaPixmap->area = NULL;
-
+
+    if (!pKaaPixmap->dirty)
+	return;
+
     bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;

+    KdCheckSync (pPixmap->drawable.pScreen);
+
     i = pPixmap->drawable.height;
     while (i--) {
	memcpy (dst, src, bytes);
	dst += dst_pitch;
	src += src_pitch;
     }
+    pKaaPixmap->dirty = FALSE;
}

static Bool
@@ -118,8 +135,8 @@

     DBG_PIXMAP(("++ 0x%08x (0x%x) (%dx%d)\n",
		  pPixmap->drawable.id,
-		  KaaGetPixmapPriv(pPixmap)->area ?
-		  KaaGetPixmapPriv(pPixmap)->area->offset : -1,
+		  pKaaPixmap->area ?
+		  pKaaPixmap->area->offset : -1,
		  pPixmap->drawable.width,
		  pPixmap->drawable.height));
     pPixmap->devKind = pitch;
@@ -132,6 +149,7 @@
kaaMoveInPixmap (PixmapPtr pPixmap)
{
     ScreenPtr	pScreen = pPixmap->drawable.pScreen;
+    KaaPixmapPriv (pPixmap);
     KaaScreenPriv (pScreen);
     int dst_pitch, src_pitch, bytes;
     unsigned char *dst, *src;
@@ -139,8 +157,8 @@

     DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n",
		  pPixmap->drawable.id,
-		  KaaGetPixmapPriv(pPixmap)->area ?
-		  KaaGetPixmapPriv(pPixmap)->area->offset : -1,
+		  pKaaPixmap->area ?
+		  pKaaPixmap->area->offset : -1,
		  pPixmap->drawable.width,
		  pPixmap->drawable.height));

@@ -152,8 +170,10 @@

     if (pKaaScr->info->UploadToScreen)
     {
-	if (pKaaScr->info->UploadToScreen(pPixmap, src, src_pitch))
+	if (pKaaScr->info->UploadToScreen(pPixmap, src, src_pitch)) {
+	    pKaaPixmap->dirty = FALSE;
	    return;
+	}
     }

     dst = pPixmap->devPrivate.ptr;
@@ -161,14 +181,13 @@

     bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;

-    KdCheckSync (pPixmap->drawable.pScreen);
-
     i = pPixmap->drawable.height;
     while (i--) {
	memcpy (dst, src, bytes);
	dst += dst_pitch;
	src += src_pitch;
     }
+    pKaaPixmap->dirty = FALSE;
}

static void
@@ -195,13 +214,12 @@
{
     KaaPixmapPriv (pPixmap);

+    KdOffscreenMarkUsed (pPixmap);
     if (pKaaPixmap->score < KAA_PIXMAP_SCORE_MAX)
-    {
	pKaaPixmap->score++;
-	if (!pKaaPixmap->area &&
-	    pKaaPixmap->score >= KAA_PIXMAP_SCORE_MOVE_IN)
-	    kaaMoveInPixmap (pPixmap);
-    }
+    if (!pKaaPixmap->area &&
+	pKaaPixmap->score >= KAA_PIXMAP_SCORE_MOVE_IN)
+	kaaMoveInPixmap (pPixmap);
}

void
@@ -265,11 +283,9 @@
     if (!pPixmap)
	return NULL;
     pKaaPixmap = KaaGetPixmapPriv(pPixmap);
-    pKaaPixmap->score = 0;
+    pKaaPixmap->score = KAA_PIXMAP_SCORE_MOVE_IN - 1;
     pKaaPixmap->area = NULL;

-    if ((pPixmap->devKind * h) >= MIN_OFFPIX_SIZE)
-	kaaPixmapAllocArea (pPixmap);
     return pPixmap;
}

@@ -407,6 +423,7 @@
	}
     }
     (*pKaaScr->info->DoneSolid) ();
+    kaaPixmapDirty(pDrawable);
     KdMarkSync(pDrawable->pScreen);
}

@@ -466,6 +483,7 @@
		    pbox, nbox, dx, dy, reverse, upsidedown,
		    bitplane, closure);
     }
+    kaaPixmapDirty(pDstDrawable);
}

static RegionPtr
@@ -575,6 +593,7 @@
	}
     }
     (*pKaaScr->info->DoneSolid) ();
+    kaaPixmapDirty(pDrawable);
     KdMarkSync(pDrawable->pScreen);
}

@@ -605,6 +624,7 @@
	fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2,
			   fbAnd (GXcopy, fg, pm),
			   fbXor (GXcopy, fg, pm));
+	kaaPixmapDirty(pDrawable);
	return;
     }
     for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
@@ -637,6 +657,7 @@
				 partX2 + xoff, partY2 + yoff);
     }
     (*pKaaScr->info->DoneSolid) ();
+    kaaPixmapDirty(pDrawable);
     KdMarkSync(pDrawable->pScreen);
}

@@ -724,6 +745,7 @@
     }

     KdCheckSync (pDrawable->pScreen);
+    kaaPixmapDirty(pDrawable);

     ppci = ppciInit;
     while (nglyph--)
@@ -889,6 +911,7 @@
	fbFillRegionSolid (pDrawable, pRegion, 0,
			   fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
     }
+    kaaPixmapDirty(pDrawable);
}

static void
Index: kaa.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kaa.h,v
retrieving revision 1.2
diff -u -r1.2 kaa.h
--- kaa.h	29 Dec 2003 06:24:01 -0000	1.2
+++ kaa.h	6 Feb 2004 22:29:51 -0000
@@ -44,6 +44,7 @@
     int		    score;
     int		    devKind;
     DevUnion	    devPrivate;
+    Bool	    dirty;
} KaaPixmapPrivRec, *KaaPixmapPrivPtr;

extern int kaaScreenPrivateIndex;
@@ -62,6 +63,9 @@
Bool
kaaPixmapIsOffscreen(PixmapPtr p);

+void
+kaaPixmapDirty(DrawablePtr pDrawable);
+
PixmapPtr
kaaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);

Index: kaapict.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kaapict.c,v
retrieving revision 1.8
diff -u -r1.8 kaapict.c
--- kaapict.c	9 Jan 2004 08:40:32 -0000	1.8
+++ kaapict.c	19 Feb 2004 22:34:37 -0000
@@ -296,6 +296,7 @@
     }

     (*pKaaScr->info->DoneSolid) ();
+    kaaPixmapDirty(pDst->pDrawable);
     KdMarkSync(pDst->pDrawable->pScreen);

     REGION_UNINIT(pDst->pDrawable->pScreen, &region);
@@ -332,12 +333,11 @@
				   width, height))
	return 1;

-
     if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
	kaaPixmapUseScreen ((PixmapPtr) pSrc->pDrawable);
     if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
	kaaPixmapUseScreen ((PixmapPtr) pDst->pDrawable);
-
+
     pSrcPix = kaaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, 
&src_off_y);
     pDstPix = kaaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, 
&dst_off_y);

@@ -382,6 +382,7 @@
     }

     (*pKaaScr->info->DoneBlend) ();
+    kaaPixmapDirty(pDst->pDrawable);
     KdMarkSync(pDst->pDrawable->pScreen);

     REGION_UNINIT(pDst->pDrawable->pScreen, &region);
@@ -426,7 +427,6 @@
				   width, height))
	return 1;

-
     if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
	kaaPixmapUseScreen ((PixmapPtr) pSrc->pDrawable);
     if (pMask && pMask->pDrawable->type == DRAWABLE_PIXMAP)
@@ -490,6 +490,7 @@
     }

     (*pKaaScr->info->DoneComposite) ();
+    kaaPixmapDirty(pDst->pDrawable);
     KdMarkSync(pDst->pDrawable->pScreen);

     REGION_UNINIT(pDst->pDrawable->pScreen, &region);
Index: kasync.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kasync.c,v
retrieving revision 1.14
diff -u -r1.14 kasync.c
--- kasync.c	2 Nov 2003 19:56:10 -0000	1.14
+++ kasync.c	6 Feb 2004 22:38:03 -0000
@@ -27,6 +27,7 @@
#include <config.h>
#endif
#include "kdrive.h"
+#include "kaa.h"

/*
  * These functions wrap the low-level fb rendering functions and
@@ -40,6 +41,7 @@
{
     KdCheckSync (pDrawable->pScreen);
     fbFillSpans (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -48,6 +50,7 @@
{
     KdCheckSync (pDrawable->pScreen);
     fbSetSpans (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -57,6 +60,7 @@
{
     KdCheckSync (pDrawable->pScreen);
     fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits);
+    kaaPixmapDirty (pDrawable);
}

RegionPtr
@@ -64,6 +68,7 @@
		 int srcx, int srcy, int w, int h, int dstx, int dsty)
{
     KdCheckSync (pSrc->pScreen);
+    kaaPixmapDirty (pDst);
     return fbCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
}

@@ -73,6 +78,7 @@
		  unsigned long bitPlane)
{
     KdCheckSync (pSrc->pScreen);
+    kaaPixmapDirty (pDst);
     return fbCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
			bitPlane);
}
@@ -82,6 +88,7 @@
		  DDXPointPtr pptInit)
{
     KdCheckSync (pDrawable->pScreen);
+    kaaPixmapDirty (pDrawable);
     fbPolyPoint (pDrawable, pGC, mode, npt, pptInit);
}

@@ -92,6 +99,7 @@

     if (pGC->lineWidth == 0)
	KdCheckSync (pDrawable->pScreen);
+    kaaPixmapDirty (pDrawable);
     fbPolyLine (pDrawable, pGC, mode, npt, ppt);
}

@@ -101,6 +109,7 @@
{
     if (pGC->lineWidth == 0)
	KdCheckSync(pDrawable->pScreen);
+    kaaPixmapDirty (pDrawable);
     fbPolySegment (pDrawable, pGC, nsegInit, pSegInit);
}

@@ -110,6 +119,7 @@
{
     if (pGC->lineWidth == 0)
	KdCheckSync(pDrawable->pScreen);
+    kaaPixmapDirty (pDrawable);
     fbPolyRectangle (pDrawable, pGC, nrects, prect);
}

@@ -124,6 +134,7 @@
     }
     else
	miPolyArc (pDrawable, pGC, narcs, pArcs);
+    kaaPixmapDirty (pDrawable);
}

#if 0
@@ -133,6 +144,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbFillPolygon (pDrawable, pGC, mode, count, pPts);
+    kaaPixmapDirty (pDrawable);
}
#endif

@@ -142,6 +154,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbPolyFillRect (pDrawable, pGC, nrect, prect);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -150,6 +163,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbPolyFillArc (pDrawable, pGC, narcs, pArcs);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -159,6 +173,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -168,6 +183,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -177,6 +193,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -187,6 +204,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbGetImage (pDrawable, x, y, w, h, format, planeMask, d);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -199,6 +217,7 @@
{
     KdCheckSync(pDrawable->pScreen);
     fbGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -210,6 +229,7 @@
{
     KdCheckSync(pWin->drawable.pScreen);
     fbSaveAreas (pPixmap, prgnSave, xorg, yorg, pWin);
+    kaaPixmapDirty ((DrawablePtr)pWin);
}

void
@@ -221,6 +241,7 @@
{
     KdCheckSync(pWin->drawable.pScreen);
     fbRestoreAreas (pPixmap, prgnSave, xorg, yorg, pWin);
+    kaaPixmapDirty ((DrawablePtr)pWin);
}

void
@@ -228,6 +249,7 @@
{
     KdCheckSync (pWin->drawable.pScreen);
     fbPaintWindow (pWin, pRegion, what);
+    kaaPixmapDirty ((DrawablePtr)pWin);
}

void
@@ -235,6 +257,7 @@
{
     KdCheckSync (pWin->drawable.pScreen);
     fbCopyWindow (pWin, ptOldOrg, prgnSrc);
+    kaaPixmapDirty ((DrawablePtr)pWin);
}

#if KD_MAX_FB > 1
@@ -246,6 +269,7 @@
{
     KdCheckSync (pDrawable->pScreen);
     fbOverlayPaintKey (pDrawable,  pRegion, pixel, layer);
+    kaaPixmapDirty (pDrawable);
}

void
@@ -253,6 +277,7 @@
{
     KdCheckSync (pWin->drawable.pScreen);
     fbOverlayCopyWindow (pWin, ptOldOrg, prgnSrc);
+    kaaPixmapDirty ((DrawablePtr)pWin);
}
#endif

Index: kdrive.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kdrive.h,v
retrieving revision 1.49
diff -u -r1.49 kdrive.h
--- kdrive.h	8 Jan 2004 08:16:24 -0000	1.49
+++ kdrive.h	6 Feb 2004 23:25:33 -0000
@@ -124,12 +124,13 @@
     int			save_offset;
     int			size;
     pointer		privData;
-
+    int			score;
+
     KdOffscreenSaveProc save;

     KdOffscreenState	state;
-
-   KdOffscreenArea	*next;
+
+    KdOffscreenArea	*next;
};

#define RR_Rotate_All	(RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
@@ -888,6 +889,9 @@
void
KdOffscreenFini (ScreenPtr pScreen);

+void
+KdOffscreenMarkUsed (PixmapPtr pPixmap);
+
/* function prototypes to be implemented by the drivers */
void
InitCard (char *name);
Index: koffscreen.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/koffscreen.c,v
retrieving revision 1.14
diff -u -r1.14 koffscreen.c
--- koffscreen.c	3 Jan 2004 11:17:44 -0000	1.14
+++ koffscreen.c	19 Feb 2004 22:48:02 -0000
@@ -26,6 +26,7 @@
#include <config.h>
#endif
#include "kdrive.h"
+#include "kaa.h"

#define DEBUG_OFFSCREEN 0
#if DEBUG_OFFSCREEN
@@ -69,9 +70,9 @@
		  KdOffscreenSaveProc save,
		  pointer privData)
{
-    KdOffscreenArea *area, **prev;
+    KdOffscreenArea *area, *begin, *best;
     KdScreenPriv (pScreen);
-    int tmp, real_size = 0;
+    int tmp, real_size = 0, best_score;

     KdOffscreenValidate (pScreen);
     if (!align)
@@ -90,7 +91,7 @@
	return NULL;
     }

-    /* Go through the areas */
+    /* Try to find a free space that'll fit. */
     for (area = pScreenPriv->off_screen_areas; area; area = area->next)
     {
	/* skip allocated areas */
@@ -117,38 +118,43 @@
	 */

	/* prev points at the first object to boot */
-	prev = (KdOffscreenArea **) &pScreenPriv->off_screen_areas;
-	while ((area = *prev))
+	best = NULL;
+	best_score = MAXINT;
+	for (begin = pScreenPriv->off_screen_areas; begin != NULL;
+	     begin = begin->next)
	{
-	    int avail;
-	    KdOffscreenArea *scan, **nprev;
-
+	    int avail, score;
+	    KdOffscreenArea *scan;
+
+	    if (begin->state == KdOffscreenLocked)
+		continue;
+
	    /* adjust size to match alignment requirement */
	    real_size = size;
-	    tmp = area->offset % align;
+	    tmp = begin->offset % align;
	    if (tmp)
		real_size += (align - tmp);

	    avail = 0;
-	    /* now see if we can make room here */
-	    for (nprev = prev; (scan = *nprev); nprev = &scan->next)
+	    score = 0;
+	    /* now see if we can make room here, and how costly it'll be. */
+	    for (scan = begin; scan != NULL; scan = scan->next)
	    {
		if (scan->state == KdOffscreenLocked)
		    break;
+		if (scan->state == KdOffscreenRemovable)
+		    score += scan->score;
		avail += scan->size;
		if (avail >= real_size)
		    break;
	    }
-	    /* space? */
-	    if (avail >= real_size)
-		break;
-
-	    /* nope, try the next area */
-	    prev = nprev;
-	    /* skip to next unlocked area */
-	    while ((area = *prev) && area->state == KdOffscreenLocked)
-		prev = &area->next;
+	    /* Is it the best option we've found so far? */
+	    if (avail >= real_size && score < best_score) {
+		best = begin;
+		best_score = score;
+	    }
	}
+	area = best;
	if (!area)
	{
	    DBG_OFFSCREEN (("Alloc 0x%x -> NOSPACE\n", size));
@@ -157,6 +163,12 @@
	    return NULL;
	}

+	/* adjust size to match alignment requirement */
+	real_size = size;
+	tmp = begin->offset % align;
+	if (tmp)
+	    real_size += (align - tmp);
+
	/*
	 * Kick out first area if in use
	 */
@@ -183,6 +195,7 @@
	new_area->state = KdOffscreenAvail;
	new_area->save = 0;
	new_area->next = area->next;
+	new_area->score = 0;
	area->next = new_area;
	area->size = real_size;
     }
@@ -195,6 +208,7 @@
	area->state = KdOffscreenRemovable;
     area->privData = privData;
     area->save = save;
+    area->score = 0;

     area->save_offset = area->offset;
     area->offset = (area->offset + align - 1) & ~(align - 1);
@@ -264,6 +278,7 @@
     area->state = KdOffscreenAvail;
     area->save = 0;
     area->offset = area->save_offset;
+    area->score = 0;

     /*
      * Find previous area
@@ -286,6 +301,29 @@
     KdOffscreenValidate (pScreen);
}

+void
+KdOffscreenMarkUsed (PixmapPtr pPixmap)
+{
+    KaaPixmapPriv (pPixmap);
+    KdScreenPriv (pPixmap->drawable.pScreen);
+    static int iter = 0;
+
+    if (!pKaaPixmap->area)
+	return;
+
+    /* The numbers here are arbitrary.  We may want to tune these. */
+    pKaaPixmap->area->score += 100;
+    if (++iter == 10) {
+	KdOffscreenArea *area;
+	for (area = pScreenPriv->off_screen_areas; area != NULL;
+	     area = area->next)
+	{
+	    if (area->state == KdOffscreenRemovable)
+		area->score = (area->score * 7) / 8;
+	}
+    }
+}
+
Bool
KdOffscreenInit (ScreenPtr pScreen)
{
@@ -303,6 +341,7 @@
     area->size = pScreenPriv->screen->memory_size - area->offset;
     area->save = 0;
     area->next = NULL;
+    area->score = 0;

     /* Add it to the free areas */
     pScreenPriv->off_screen_areas = area;
Index: kpict.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kpict.c,v
retrieving revision 1.6
diff -u -r1.6 kpict.c
--- kpict.c	14 Oct 2003 05:07:39 -0000	1.6
+++ kpict.c	6 Feb 2004 23:30:31 -0000
@@ -26,6 +26,7 @@
#include <config.h>
#endif
#include "kdrive.h"
+#include "kaa.h"
#include <picturestr.h>
#include <mipict.h>
#include <fbpict.h>
@@ -57,6 +58,7 @@
		 yDst,
		 width,
		 height);
+    kaaPixmapDirty(pDst->pDrawable);
}

void
xserver-trident-5.tar.gz (application/x-gzip-compressed, 9.9 KB) - not displayed
xserver-ati-r128pitch.diff (text/plain, 1.8 KB)
Index: ati_drawtmp.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_drawtmp.h,v
retrieving revision 1.4
diff -u -r1.4 ati_drawtmp.h
--- ati_drawtmp.h	30 Dec 2003 08:45:53 -0000	1.4
+++ ati_drawtmp.h	19 Feb 2004 22:56:28 -0000
@@ -54,8 +54,18 @@
	dst_pitch = pDst->devKind;
	dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
	    pScreenPriv->screen->memory_base);
-	if ((dst_pitch & (atis->kaa.offscreenPitch - 1)) != 0)
-		ATI_FALLBACK(("Bad dst pitch 0x%x\n", dst_pitch));
+	/* On the R128, depending on the bpp the screen can be set up so that it
+	 * doesn't meet the offscreenPitch requirement but can still be
+	 * accelerated, so we check the specific pitch requirement of alignment
+	 * to 8 pixels.
+	 */
+	if (!atic->is_radeon) {
+		if (dst_pitch % pDst->drawable.bitsPerPixel != 0)
+			ATI_FALLBACK(("Bad dst pitch 0x%x\n", dst_pitch));
+	} else {
+		if (dst_pitch % atis->kaa.offscreenPitch != 0)
+			ATI_FALLBACK(("Bad dst pitch 0x%x\n", dst_pitch));
+	}
	if ((dst_offset & (atis->kaa.offscreenByteAlign - 1)) != 0)
		ATI_FALLBACK(("Bad dst offset 0x%x\n", dst_offset));

@@ -63,8 +73,15 @@
		src_pitch = pSrc->devKind;
		src_offset = ((CARD8 *)pSrc->devPrivate.ptr -
		    pScreenPriv->screen->memory_base);
-		if ((src_pitch & (atis->kaa.offscreenPitch - 1)) != 0)
-			ATI_FALLBACK(("Bad src pitch 0x%x\n", src_pitch));
+		if (!atic->is_radeon) {
+			if (src_pitch % pSrc->drawable.bitsPerPixel != 0)
+				ATI_FALLBACK(("Bad src pitch 0x%x\n",
+				    src_pitch));
+		} else {
+			if (src_pitch % atis->kaa.offscreenPitch != 0)
+				ATI_FALLBACK(("Bad src pitch 0x%x\n",
+				    src_pitch));
+		}
		if ((src_offset & (atis->kaa.offscreenByteAlign - 1)) != 0)
			ATI_FALLBACK(("Bad src offset 0x%x\n", src_offset));
	}
xserver-fb-satfix.diff (text/plain, 3.3 KB)
Index: fbcompose.c
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbcompose.c,v
retrieving revision 1.19
diff -u -r1.19 fbcompose.c
--- fbcompose.c	28 Dec 2003 12:58:00 -0000	1.19
+++ fbcompose.c	18 Feb 2004 18:52:32 -0000
@@ -759,93 +759,6 @@
     }
}

-void
-fbCombineSaturateU (FbCompositeOperand   *src,
-		    FbCompositeOperand   *msk,
-		    FbCompositeOperand   *dst)
-{
-    CARD32  s = fbCombineMaskU (src, msk), d;
-#if 0
-    CARD16  sa, da;
-    CARD16  ad, as;
-    CARD16  t;
-    CARD32  m,n,o,p;
-
-    d = (*dst->fetch) (dst);
-    sa = s >> 24;
-    da = ~d >> 24;
-    if (sa <= da)
-    {
-	m = FbAdd(s,d,0,t);
-	n = FbAdd(s,d,8,t);
-	o = FbAdd(s,d,16,t);
-	p = FbAdd(s,d,24,t);
-    }
-    else
-    {
-	as = (da << 8) / sa;
-	ad = 0xff;
-	m = FbGen(s,d,0,as,ad,t,u,v);
-	n = FbGen(s,d,8,as,ad,t,u,v);
-	o = FbGen(s,d,16,as,ad,t,u,v);
-	p = FbGen(s,d,24,as,ad,t,u,v);
-    }
-    (*dst->store) (dst, m|n|o|p);
-#else
-    if ((s >> 24) == 0xff)
-	(*dst->store) (dst, s);
-    else
-    {
-	d = (*dst->fetch) (dst);
-	if ((s >> 24) > (d >> 24))
-	    (*dst->store) (dst, s);
-    }
-#endif
-}
-
-void
-fbCombineSaturateC (FbCompositeOperand   *src,
-		    FbCompositeOperand   *msk,
-		    FbCompositeOperand   *dst)
-{
-    FbCompSrc	cs;
-    CARD32  s, d;
-    CARD16  sa, sr, sg, sb, da;
-    CARD16  t, u, v;
-    CARD32  m,n,o,p;
-
-    cs = fbCombineMaskC (src, msk);
-    d = (*dst->fetch) (dst);
-    s = cs.value;
-    sa = (cs.alpha >> 24) & 0xff;
-    sr = (cs.alpha >> 16) & 0xff;
-    sg = (cs.alpha >>  8) & 0xff;
-    sb = (cs.alpha      ) & 0xff;
-    da = ~d >> 24;
-
-    if (sb <= da)
-	m = FbAdd(s,d,0,t);
-    else
-	m = FbGen (s, d, 0, (da << 8) / sb, 0xff, t, u, v);
-
-    if (sg <= da)
-	n = FbAdd(s,d,8,t);
-    else
-	n = FbGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v);
-
-    if (sr < da)
-	o = FbAdd(s,d,16,t);
-    else
-	o = FbGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v);
-
-    if (sa <= da)
-	p = FbAdd(s,d,24,t);
-    else
-	p = FbGen (s, d, 24, (da << 8) / sa, 0xff, t, u, v);
-
-    (*dst->store) (dst, m|n|o|p);
-}
-
/*
  * All of the disjoint composing functions

@@ -1521,7 +1434,7 @@
     fbCombineAtopReverseU,
     fbCombineXorU,
     fbCombineAddU,
-    fbCombineDisjointOverU, /* Saturate */
+    fbCombineDisjointOverReverseU, /* Saturate */
     0,
     0,
     fbCombineClear,
@@ -1568,7 +1481,7 @@
     fbCombineAtopReverseC,
     fbCombineXorC,
     fbCombineAddC,
-    fbCombineDisjointOverC, /* Saturate */
+    fbCombineDisjointOverReverseC, /* Saturate */
     0,
     0,
     fbCombineClear,	    /* 0x10 */
Index: fbpict.h
===================================================================
RCS file: /cvs/xserver/xserver/fb/fbpict.h,v
retrieving revision 1.16
diff -u -r1.16 fbpict.h
--- fbpict.h	15 Jan 2004 09:09:29 -0000	1.16
+++ fbpict.h	18 Feb 2004 18:52:15 -0000
@@ -295,15 +295,8 @@
	       FbCompositeOperand    *msk,
	       FbCompositeOperand    *dst);

-void
-fbCombineSaturateU (FbCompositeOperand   *src,
-		    FbCompositeOperand   *msk,
-		    FbCompositeOperand   *dst);
-
-void
-fbCombineSaturateC (FbCompositeOperand   *src,
-		    FbCompositeOperand   *msk,
-		    FbCompositeOperand   *dst);
+#define fbCombineSaturateU fbCombineDisjointOverReverseU
+#define fbCombineSaturateC fbCombineDisjointOverReverseC

CARD8
fbCombineDisjointOutPart (CARD8 a, CARD8 b);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.