summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilman Sauerbeck <tilman@code-monkey.de>2006-09-07 22:21:19 +0200
committerTilman Sauerbeck <tilman@code-monkey.de>2006-09-07 22:21:19 +0200
commitad57c370ba8ffcbf0b7cf404c61ed01bc924ddd5 (patch)
tree40b201514f05b2ae3f1b4fa78653f7527b3ebe7b
parentc39749d6e0e967cd12bcc629c3840905e07dd60c (diff)
Use the right dithering mode for r5g5b5 textures.
This makes all of rendercheck's blend tests work.
-rw-r--r--src/mga_exa.c43
-rw-r--r--src/mga_reg.h7
2 files changed, 32 insertions, 18 deletions
diff --git a/src/mga_exa.c b/src/mga_exa.c
index 460226d..6345f5b 100644
--- a/src/mga_exa.c
+++ b/src/mga_exa.c
@@ -157,25 +157,32 @@ mgaGetPixmapPitch(PixmapPtr pPix)
return exaGetPixmapPitch(pPix) / (pPix->drawable.bitsPerPixel >> 3);
}
-static Bool
-mgaSetup(MGAPtr pMga, int dest_bpp, int wait)
+static CARD32
+mgaGetMACCESS(PixmapPtr pixmap, PicturePtr pict)
{
- unsigned int maccess = 0;
- static const unsigned int maccess_table[5] = {
- 0, /* dummy */
- 0, /* 8 bpp, PW8 */
- 1, /* 16 bpp, PW16 */
- 3, /* 24 bpp, PW24 */
- 2, /* 32 bpp, PW32 */
- };
+ switch (pixmap->drawable.bitsPerPixel) {
+ case 8:
+ return MGAMAC_PW8;
+ case 16:
+ if (pict &&
+ (pict->format == PICT_x1r5g5b5 || pict->format == PICT_a1r5g5b5))
+ return MGAMAC_PW16 | MGAMAC_DIT555;
+ else
+ return MGAMAC_PW16;
+ case 24:
+ return MGAMAC_PW24;
+ default:
+ return MGAMAC_PW32;
+ }
+}
+static Bool
+mgaSetup(MGAPtr pMga, PixmapPtr pixmap, PicturePtr pict, int wait)
+{
WAITFIFO(wait + 4);
- /* Set the format of the destination pixmap.
- * Taken from MGAStormEngineInit().
- */
- maccess |= maccess_table[dest_bpp / 8];
- OUTREG(MGAREG_MACCESS, maccess);
+ /* Set the format of the destination pixmap */
+ OUTREG(MGAREG_MACCESS, mgaGetMACCESS(pixmap, pict));
OUTREG(MGAREG_CXBNDRY, 0xffff0000);
OUTREG(MGAREG_YTOP, 0x00000000);
@@ -217,7 +224,7 @@ mgaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)
dwgctl = MGADWG_TRAP | MGADWG_SOLID | MGADWG_ARZERO |
MGADWG_SGNZERO | MGADWG_SHIFTZERO | mgaRop[alu];
- mgaSetup(pMga, pPixmap->drawable.bitsPerPixel, 5);
+ mgaSetup(pMga, pPixmap, NULL, 5);
OUTREG(MGAREG_PITCH, mgaGetPixmapPitch(pPixmap));
OUTREG(MGAREG_DSTORG, exaGetPixmapOffset(pPixmap));
@@ -267,7 +274,7 @@ mgaPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int xdir, int ydir, int alu,
dwgctl = mgaRop[alu] | MGADWG_SHIFTZERO | MGADWG_BITBLT | MGADWG_BFCOL;
pMga->src_pitch = mgaGetPixmapPitch(pSrc);
- mgaSetup(pMga, pDst->drawable.bitsPerPixel, 7);
+ mgaSetup(pMga, pDst, NULL, 7);
OUTREG(MGAREG_PITCH, mgaGetPixmapPitch(pDst));
OUTREG(MGAREG_SRCORG, exaGetPixmapOffset(pSrc));
OUTREG(MGAREG_DSTORG, exaGetPixmapOffset(pDst));
@@ -549,7 +556,7 @@ mgaPrepareComposite(int op, PicturePtr pSrcPict, PicturePtr pMaskPict,
PMGA(pDst);
CARD32 ds0 = 0, ds1 = 0, cmd, blendcntl;
- mgaSetup(pMga, pDst->drawable.bitsPerPixel, 3);
+ mgaSetup(pMga, pDst, pDstPict, 3);
OUTREG(MGAREG_FCOL, 0xff000000);
OUTREG(MGAREG_DSTORG, exaGetPixmapOffset(pDst));
OUTREG(MGAREG_PITCH, mgaGetPixmapPitch(pDst));
diff --git a/src/mga_reg.h b/src/mga_reg.h
index 9a64955..e67158c 100644
--- a/src/mga_reg.h
+++ b/src/mga_reg.h
@@ -133,6 +133,13 @@
#define MGAOPM_DMA_BLIT (0x01 << 2)
#define MGAOPM_DMA_VECTOR (0x10 << 2)
+/* MACCESS register additives */
+#define MGAMAC_PW8 0x00
+#define MGAMAC_PW16 0x01
+#define MGAMAC_PW24 0x03 /* not a typo */
+#define MGAMAC_PW32 0x02 /* not a typo */
+#define MGAMAC_DIT555 0x80000000
+
/* DWGCTL register additives */
/* Lines */