summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2009-02-03 18:57:14 +0100
committerLuc Verhaegen <libv@skynet.be>2009-02-03 18:57:14 +0100
commita0f97b00ebe363e13319afe3b4feb4b58610c6fe (patch)
treefc2a61150d45c74fe8b59cf2ff4981cacc666831
parent1148e8f5da915cb303e09de551d266905a75fecb (diff)
Get rid of pVia->Bpl amd pVia->Bpp.
Introduce pVia->RegPitch, to be moved into a future accel struct. By predefining this, which is true for XAA anyway, we save quite some overhead.
-rw-r--r--src/via_accel.c66
-rw-r--r--src/via_driver.c4
-rw-r--r--src/via_driver.h2
-rw-r--r--src/via_memory.c12
4 files changed, 31 insertions, 53 deletions
diff --git a/src/via_accel.c b/src/via_accel.c
index 36c9412..93d78b0 100644
--- a/src/via_accel.c
+++ b/src/via_accel.c
@@ -340,7 +340,7 @@ VIASetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2)
pVia->justSetup = 0;
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
#ifdef DEBUG_EXTRA
- ErrorF("ClipRect, (%4d,%4d)-(%4d,%4d) \n", x1, y1, x2, y2 );
+ ErrorF("ClipRect, (%4d,%4d)-(%4d,%4d) \n", x1, y1, x2, y2);
#endif
CBUFFER(buf, VIA_REG_CLIPTL, ((y1 << 16) | x1));
@@ -415,8 +415,8 @@ VIASubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
if (!w || !h)
return;
- srcBase = y1*pVia->Bpl + x1*pVia->Bpp;
- dstBase = y2*pVia->Bpl + x2*pVia->Bpp;
+ srcBase = (y1 * pScrn->displayWidth + x1) * pScrn->bitsPerPixel / 8;
+ dstBase = (y2 * pScrn->displayWidth + x2) * pScrn->bitsPerPixel / 8;
x1 = (srcBase & 31);
x2 = (dstBase & 31);
@@ -448,12 +448,11 @@ VIASubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
}
COND_CLEAR_CBUFFER(buf, pVia);
- CBUFFER(buf, VIA_REG_GEMODE, tdc->mode );
+ CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, (srcBase & ~31) >> 3);
CBUFFER(buf, VIA_REG_DSTBASE, (dstBase & ~31) >> 3);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- (pVia->Bpl >> 3) | ((pVia->Bpl >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, ((y1 << 16) | x1));
CBUFFER(buf, VIA_REG_DSTPOS, ((y2 << 16) | x2));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -501,16 +500,12 @@ VIASubsequentSolidFillRect(ScrnInfoPtr pScrn,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
CBUFFER(buf, VIA_REG_FGCOLOR, pVia->SavedFgColor);
CBUFFER(buf, VIA_REG_GECMD, pVia->SavedCmd);
dispatchCBufferAGP(pVia, buf);
-
}
/*
@@ -570,10 +565,7 @@ VIASubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, int patOffy,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
CBUFFER(buf, VIA_REG_PATADDR, dwPatOffset);
@@ -602,7 +594,8 @@ VIASetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny,
#endif
pVia->SavedCmd = cmd;
- pVia->SavedPatternAddr = (patternx * pVia->Bpp + patterny * pVia->Bpl);
+ pVia->SavedPatternAddr = (patternx + patterny * pScrn->displayWidth) *
+ (pScrn->bitsPerPixel >> 3);
}
/*
@@ -628,10 +621,7 @@ VIASubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, int patOffy
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
CBUFFER(buf, VIA_REG_PATADDR, dwPatAddr);
@@ -693,10 +683,7 @@ VIASubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y,
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, 0);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -746,8 +733,8 @@ VIASubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, int x, int y,
ViaTwodContext *tdc = &pVia->td;
CARD32 srcBase,dstBase;
- srcBase = srcy*pVia->Bpl + srcx*pVia->Bpp;
- dstBase = y*pVia->Bpl + x*pVia->Bpp;
+ srcBase = (srcy * pScrn->displayWidth + srcx) * (pScrn->bitsPerPixel >> 3);
+ dstBase = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel >> 3);
x = (dstBase & 31);
srcx = srcBase & 7;
@@ -772,9 +759,7 @@ VIASubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, int x, int y,
CBUFFER(buf, VIA_REG_KEYCONTROL, 0x0);
CBUFFER(buf, VIA_REG_SRCBASE, (srcBase & ~7) >> 3);
CBUFFER(buf, VIA_REG_DSTBASE, (dstBase & ~31) >> 3);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, (srcx << 6) | offset);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -836,10 +821,7 @@ VIASubsequentImageWriteRect(ScrnInfoPtr pScrn,
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, 0);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -920,10 +902,7 @@ VIASubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
/* major = 2*dmaj, minor = 2*dmin, err = -dmaj - ((bias >> octant) & 1) */
/* K1 = 2*dmin K2 = 2*(dmin - dmax) */
/* Error Term = (StartX<EndX) ? (2*dmin - dmax - 1) : (2*(dmin - dmax)) */
@@ -953,9 +932,7 @@ VIASubsequentSolidHorVertLine(ScrnInfoPtr pScrn,
CBUFFER(buf, VIA_REG_FGCOLOR, pVia->SavedFgColor);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
if (dir == DEGREES_0) {
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
@@ -1061,9 +1038,7 @@ VIASubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
/* major = 2*dmaj, minor = 2*dmin, err = -dmaj - ((bias >> octant) & 1) */
/* K1 = 2*dmin K2 = 2*(dmin - dmax) */
@@ -1321,6 +1296,11 @@ VIAInitAccel(ScrnInfoPtr pScrn, ScreenPtr pScreen)
VIAXAAInit(pScrn, pVia->AccelInfoRec);
+ /* used _very_ often. */
+ pVia->RegPitch = (pScrn->displayWidth * pScrn->bitsPerPixel) >> 6;
+ pVia->RegPitch |= pVia->RegPitch << 16;
+ pVia->RegPitch |= VIA_PITCH_ENABLE;
+
pVia->justSetup = 0; /* command buffer tracking... */
return XAAInit(pScreen, pVia->AccelInfoRec);
}
diff --git a/src/via_driver.c b/src/via_driver.c
index 352073b..eca749c 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1361,10 +1361,6 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
xf86PrintModes(pScrn);
- /* Set up screen parameters. */
- pVia->Bpp = pScrn->bitsPerPixel >> 3;
- pVia->Bpl = pScrn->displayWidth * pVia->Bpp;
-
#ifdef USE_FB
if (xf86LoadSubModule(pScrn, "fb") == NULL) {
VIAFreeRec(pScrn);
diff --git a/src/via_driver.h b/src/via_driver.h
index 7644391..6a7ee90 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -141,7 +141,6 @@ typedef struct{
typedef struct _VIA {
int scrnIndex;
VIARegRec SavedReg;
- int Bpp, Bpl;
/* These are physical addresses. */
unsigned long FrameBufferBase;
@@ -201,6 +200,7 @@ typedef struct _VIA {
/* Support for XAA acceleration */
struct _XAAInfoRec *AccelInfoRec;
+ CARD32 RegPitch; /* used _very_ often */
xRectangle Rect;
CARD32 SavedCmd;
CARD32 SavedFgColor;
diff --git a/src/via_memory.c b/src/via_memory.c
index a946166..f651817 100644
--- a/src/via_memory.c
+++ b/src/via_memory.c
@@ -210,10 +210,11 @@ ViaMemFBAlloc(ScrnInfoPtr pScrn, unsigned long size, CARD8 alignment)
*
*/
void
-ViaMemInit(ScrnInfoPtr pScrn, ScreenPtr pScreen)
+ViaMemInit(ScrnInfoPtr pScrn, ScreenPtr pScreen)
{
VIAPtr pVia = VIAPTR(pScrn);
unsigned long offset, size;
+ CARD16 Bpp = pScrn->bitsPerPixel >> 3;
VIAFUNC(pScrn);
@@ -221,8 +222,8 @@ ViaMemInit(ScrnInfoPtr pScrn, ScreenPtr pScreen)
pVia->FBFreeStart, pVia->FBFreeSize);
/* Why doesn't the FB manager handle alignment itself? */
- offset = (pVia->FBFreeStart + pVia->Bpp - 1 ) / pVia->Bpp;
- size = pVia->FBFreeSize / pVia->Bpp - offset;
+ offset = (pVia->FBFreeStart + Bpp - 1 ) / Bpp;
+ size = pVia->FBFreeSize / Bpp - offset;
if (size > 0)
xf86InitFBManagerLinear(pScreen, offset, size);
@@ -252,11 +253,12 @@ ViaMemFBAlloc(ScrnInfoPtr pScrn, unsigned long size, CARD8 alignment)
struct ViaMem *Mem;
FBLinearPtr linear;
unsigned long tempsize;
+ CARD16 Bpp = pScrn->bitsPerPixel >> 3;
VIAFUNC(pScrn);
/* Make sure we don't truncate requested size */
- tempsize = (size + alignment + pVia->Bpp - 1) / pVia->Bpp;
+ tempsize = (size + alignment + Bpp - 1) / Bpp;
linear = xf86AllocateOffscreenLinear(pScrn->pScreen, tempsize, 32,
NULL, NULL, NULL);
@@ -264,7 +266,7 @@ ViaMemFBAlloc(ScrnInfoPtr pScrn, unsigned long size, CARD8 alignment)
return NULL;
Mem = xnfcalloc(sizeof(struct ViaMem), 1);
- Mem->Base = linear->offset * pVia->Bpp;
+ Mem->Base = linear->offset * Bpp;
/* adjust for alignment */
if (alignment) {