[xserver-commit] xserver/hw/kdrive/ati r128_blendtmp.h,NONE,1.1.2.1 Makefile.am,1.2.2.1,1.2.2.2 ati_draw.c,1.5.2.2,1.5.2.3 ati_drawtmp.h,1.1.2.1,1.1.2.2 ati_reg.h,1.2.2.1,1.2.2.2

Eric Anholt xserver-commit@pdx.freedesktop.org
Tue, 23 Dec 2003 14:29:40 -0800


Committed by: anholt

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

Modified Files:
      Tag: dri-0-1-branch
	Makefile.am ati_draw.c ati_drawtmp.h ati_reg.h 
Added Files:
      Tag: dri-0-1-branch
	r128_blendtmp.h 
Log Message:
- Implement acceleration of Composite on R128 when there is no mask,
  no transformation, no repeat, and only certain ops are used.
- Add debugging output for software fallbacks for Composite.
- Allow pixmaps in offscreen that don't match root depth.
- Clean up some mess in ati_reg.h.

Many thanks to andersca for a lot of this code.


--- NEW FILE: r128_blendtmp.h ---
(This appears to be a binary file; contents omitted.)

Index: Makefile.am
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/Makefile.am,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -d -r1.2.2.1 -r1.2.2.2
--- Makefile.am	1 Dec 2003 22:56:06 -0000	1.2.2.1
+++ Makefile.am	23 Dec 2003 22:29:38 -0000	1.2.2.2
@@ -44,6 +44,7 @@
 	ati.c		\
 	ati.h		\
 	ati_reg.h	\
+	r128_blendtmp.h	\
 	$(DRI_SOURCES)
 
 Xati_SOURCES = \

Index: ati_draw.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.c,v
retrieving revision 1.5.2.2
retrieving revision 1.5.2.3
diff -u -d -r1.5.2.2 -r1.5.2.3
--- ati_draw.c	10 Dec 2003 05:01:29 -0000	1.5.2.2
+++ ati_draw.c	23 Dec 2003 22:29:38 -0000	1.5.2.3
@@ -73,9 +73,41 @@
     /* GXset        */      0xff,         /* 1 */
 };
 
+static CARD32 R128BlendOp[] = {
+	/* Clear */
+	R128_ALPHA_BLEND_SRC_ZERO	 | R128_ALPHA_BLEND_DST_ZERO,
+	/* Src */
+	R128_ALPHA_BLEND_SRC_ONE	 | R128_ALPHA_BLEND_DST_ZERO,
+	/* Dst */
+	R128_ALPHA_BLEND_SRC_ZERO	 | R128_ALPHA_BLEND_DST_ONE,
+	/* Over */
+	R128_ALPHA_BLEND_SRC_ONE	 | R128_ALPHA_BLEND_DST_INVSRCALPHA,
+	/* OverReverse */
+	R128_ALPHA_BLEND_SRC_INVDSTALPHA | R128_ALPHA_BLEND_DST_ONE,
+	/* In */
+	R128_ALPHA_BLEND_SRC_DSTALPHA	 | R128_ALPHA_BLEND_DST_ZERO,
+	/* InReverse */
+	R128_ALPHA_BLEND_SRC_ZERO	 | R128_ALPHA_BLEND_DST_SRCALPHA,
+	/* Out */
+	R128_ALPHA_BLEND_SRC_INVDSTALPHA | R128_ALPHA_BLEND_DST_ZERO,
+	/* OutReverse */
+	R128_ALPHA_BLEND_SRC_ZERO	 | R128_ALPHA_BLEND_DST_INVSRCALPHA,
+	/* Atop */
+	R128_ALPHA_BLEND_SRC_DSTALPHA	 | R128_ALPHA_BLEND_DST_INVSRCALPHA,
+	/* AtopReverse */
+	R128_ALPHA_BLEND_SRC_INVDSTALPHA | R128_ALPHA_BLEND_DST_SRCALPHA,
+	/* Xor */
+	R128_ALPHA_BLEND_SRC_INVDSTALPHA | R128_ALPHA_BLEND_DST_INVSRCALPHA,
+	/* Add */
+	R128_ALPHA_BLEND_SRC_ONE	 | R128_ALPHA_BLEND_DST_ONE,
+};
+
 int copydx, copydy;
 int fifo_size;
 ATIScreenInfo *accel_atis;
+int src_pitch;
+int src_offset;
+int src_bpp;
 
 static void
 ATIWaitAvailMMIO(int n)
@@ -313,14 +345,34 @@
 	buf->used = 0;
 	return buf;
 }
+#endif /* USE_DRI */
+
+static Bool
+R128GetDatatype(CARD32 format, CARD32 *type)
+{
+	switch (format) {
+	case PICT_a8r8g8b8:
+		*type = R128_DATATYPE_ARGB_8888;
+		return TRUE;
+	case PICT_r5g6b5:
+		*type = R128_DATATYPE_RGB_565;
+		return TRUE;
+	}
+
+	ErrorF ("Unsupported format: %x\n", format);
+
+	return FALSE;
+}
 
+#ifdef USE_DRI
 #define USE_DMA
 #include "ati_drawtmp.h"
-
+#include "r128_blendtmp.h"
 #endif /* USE_DRI */
 
 #undef USE_DMA
 #include "ati_drawtmp.h"
+#include "r128_blendtmp.h"
 
 static void
 ATIDoneSolid(void)
@@ -385,6 +437,11 @@
 		atis->kaa.Solid = ATISolidDMA;
 		atis->kaa.PrepareCopy = ATIPrepareCopyDMA;
 		atis->kaa.Copy = ATICopyDMA;
+		if (!atic->is_radeon && !atis->is_24bpp) {
+			atis->kaa.PrepareBlend = R128PrepareBlendDMA;
+			atis->kaa.Blend = R128BlendDMA;
+			atis->kaa.DoneBlend = R128DoneBlendDMA;
+		}
 	} else {
 #else
 	{
@@ -393,6 +450,11 @@
 		atis->kaa.Solid = ATISolidMMIO;
 		atis->kaa.PrepareCopy = ATIPrepareCopyMMIO;
 		atis->kaa.Copy = ATICopyMMIO;
+		if (!atic->is_radeon && !atis->is_24bpp) {
+			atis->kaa.PrepareBlend = R128PrepareBlendMMIO;
+			atis->kaa.Blend = R128BlendMMIO;
+			atis->kaa.DoneBlend = R128DoneBlendMMIO;
+		}
 	}
 	atis->kaa.DoneSolid = ATIDoneSolid;
 	atis->kaa.DoneCopy = ATIDoneCopy;

Index: ati_drawtmp.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/Attic/ati_drawtmp.h,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- ati_drawtmp.h	1 Dec 2003 22:56:06 -0000	1.1.2.1
+++ ati_drawtmp.h	23 Dec 2003 22:29:38 -0000	1.1.2.2
@@ -25,7 +25,8 @@
 
 #ifdef USE_DMA
 #define TAG(x)		x##DMA
-#define LOCALS		RING_LOCALS
+#define LOCALS		(void)atic; \
+			RING_LOCALS
 #define BEGIN(x)	BEGIN_RING(x * 2)
 #define OUT_REG(reg, val) OUT_RING_REG(reg, val)
 #define END()		ADVANCE_RING()
@@ -43,7 +44,7 @@
 	KdScreenPriv(pDst->drawable.pScreen);
 	ATIScreenInfo(pScreenPriv);
 	ATICardInfo(pScreenPriv);
-	int dst_offset, dst_pitch, src_offset = 0, src_pitch = 0;
+	int dst_offset, dst_pitch;
 	int bpp = pScreenPriv->screen->fb[0].bitsPerPixel;
 	LOCALS;
 

Index: ati_reg.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_reg.h,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -d -r1.2.2.1 -r1.2.2.2
--- ati_reg.h	1 Dec 2003 22:56:06 -0000	1.2.2.1
+++ ati_reg.h	23 Dec 2003 22:29:38 -0000	1.2.2.2
@@ -48,20 +48,23 @@
 #define RADEON_REG_DST_Y_X			0x1438
 #define RADEON_REG_DST_HEIGHT_WIDTH		0x143c
 #define RADEON_REG_DP_GUI_MASTER_CNTL		0x146c
-#define RADEON_REG_DP_BRUSH_FRGD_CLR		0x147c
 # define RADEON_GMC_SRC_PITCH_OFFSET_CNTL	(1    <<  0)
 # define RADEON_GMC_DST_PITCH_OFFSET_CNTL	(1    <<  1)
 # define RADEON_GMC_BRUSH_SOLID_COLOR		(13   <<  4)
 # define RADEON_GMC_BRUSH_NONE			(15   <<  4)
 # define RADEON_GMC_SRC_DATATYPE_COLOR		(3    << 12)
 # define RADEON_DP_SRC_SOURCE_MEMORY		(2    << 24)
+# define RADEON_GMC_3D_FCN_EN			(1    << 27)
 # define RADEON_GMC_CLR_CMP_CNTL_DIS		(1    << 28)
 # define RADEON_GMC_AUX_CLIP_DIS		(1    << 29)
+#define RADEON_REG_DP_BRUSH_FRGD_CLR		0x147c
+#define RADEON_REG_DST_WIDTH_HEIGHT		0x1598
+#define RADEON_REG_CLR_CMP_CNTL			0x15c0
+#define RADEON_REG_AUX_SC_CNTL			0x1660
 #define RADEON_REG_DP_CNTL			0x16c0
 # define RADEON_DST_X_LEFT_TO_RIGHT		(1 <<  0)
 # define RADEON_DST_Y_TOP_TO_BOTTOM		(1 <<  1)
-#define RADEON_REG_DST_WIDTH_HEIGHT		0x1598
-#define RADEON_REG_AUX_SC_CNTL			0x1660
+#define RADEON_REG_DP_MIX			0x16c8
 #define RADEON_REG_DP_WRITE_MASK		0x16cc
 #define RADEON_REG_DEFAULT_OFFSET		0x16e0
 #define RADEON_REG_DEFAULT_PITCH		0x16e4
@@ -76,28 +79,112 @@
 # define RADEON_RB2D_DC_FLUSH_ALL		0xf
 # define RADEON_RB2D_DC_BUSY			(1 << 31)
 
-#define RADEON_CP_PACKET0                           0x00000000
-#define RADEON_CP_PACKET1                           0x40000000
-#define RADEON_CP_PACKET2                           0x80000000
+#define RADEON_CP_PACKET0			0x00000000
+#define RADEON_CP_PACKET1			0x40000000
+#define RADEON_CP_PACKET2			0x80000000
 
 #define R128_REG_PC_NGUI_CTLSTAT		0x0184
 # define R128_PC_BUSY				(1 << 31)
+#define R128_REG_PCI_GART_PAGE			0x017c
+#define R128_REG_PC_NGUI_CTLSTAT		0x0184
+#define R128_REG_BM_CHUNK_0_VAL			0x0a18
+# define R128_BM_PTR_FORCE_TO_PCI		(1 << 21)
+# define R128_BM_PM4_RD_FORCE_TO_PCI		(1 << 22)
+# define R128_BM_GLOBAL_FORCE_TO_PCI		(1 << 23)
 #define R128_REG_GUI_STAT			0x1740
 # define R128_GUI_ACTIVE			(1 << 31)
-#define R128_REG_PCI_GART_PAGE          0x017c
-#define R128_REG_PC_NGUI_CTLSTAT	0x0184
-#define R128_REG_BM_CHUNK_0_VAL         0x0a18
-# define R128_BM_PTR_FORCE_TO_PCI    (1 << 21)
-# define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22)
-# define R128_BM_GLOBAL_FORCE_TO_PCI (1 << 23)
+#define R128_REG_TEX_CNTL			0x1800
 
-# define R128_PM4_NONPM4                 (0  << 28)
-# define R128_PM4_192PIO                 (1  << 28)
-# define R128_PM4_192BM                  (2  << 28)
-# define R128_PM4_128PIO_64INDBM         (3  << 28)
-# define R128_PM4_128BM_64INDBM          (4  << 28)
-# define R128_PM4_64PIO_128INDBM         (5  << 28)
-# define R128_PM4_64BM_128INDBM          (6  << 28)
-# define R128_PM4_64PIO_64VCBM_64INDBM   (7  << 28)
-# define R128_PM4_64BM_64VCBM_64INDBM    (8  << 28)
-# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
+#define R128_REG_SCALE_SRC_HEIGHT_WIDTH		0x1994
+#define R128_REG_SCALE_OFFSET_0			0x1998
+#define R128_REG_SCALE_PITCH			0x199c
+#define R128_REG_SCALE_X_INC			0x19a0
+#define R128_REG_SCALE_Y_INC			0x19a4
+#define R128_REG_SCALE_HACC			0x19a8
+#define R128_REG_SCALE_VACC			0x19ac
+#define R128_REG_SCALE_DST_X_Y			0x19b0
+#define R128_REG_SCALE_DST_HEIGHT_WIDTH		0x19b4
+#define R128_REG_SCALE_3D_CNTL			0x1a00
+# define R128_SCALE_DITHER_ERR_DIFF		(0  <<  1)
+# define R128_SCALE_DITHER_TABLE		(1  <<  1)
+# define R128_TEX_CACHE_SIZE_FULL		(0  <<  2)
+# define R128_TEX_CACHE_SIZE_HALF		(1  <<  2)
+# define R128_DITHER_INIT_CURR			(0  <<  3)
+# define R128_DITHER_INIT_RESET			(1  <<  3)
+# define R128_ROUND_24BIT			(1  <<  4)
+# define R128_TEX_CACHE_DISABLE			(1  <<  5)
+# define R128_SCALE_3D_NOOP			(0  <<  6)
+# define R128_SCALE_3D_SCALE			(1  <<  6)
+# define R128_SCALE_3D_TEXMAP_SHADE		(2  <<  6)
+# define R128_SCALE_PIX_BLEND			(0  <<  8)
+# define R128_SCALE_PIX_REPLICATE		(1  <<  8)
+# define R128_TEX_CACHE_SPLIT			(1  <<  9)
+# define R128_APPLE_YUV_MODE			(1  << 10)
+# define R128_TEX_CACHE_PALLETE_MODE		(1  << 11)
+# define R128_ALPHA_COMB_ADD_CLAMP		(0  << 12)
+# define R128_ALPHA_COMB_ADD_NCLAMP		(1  << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP	(2  << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP	(3  << 12)
+# define R128_FOG_TABLE				(1  << 14)
+# define R128_SIGNED_DST_CLAMP			(1  << 15)
+# define R128_ALPHA_BLEND_SRC_ZERO		(0  << 16)
+# define R128_ALPHA_BLEND_SRC_ONE		(1  << 16)
+# define R128_ALPHA_BLEND_SRC_SRCCOLOR		(2  << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR	(3  << 16)
+# define R128_ALPHA_BLEND_SRC_SRCALPHA		(4  << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCALPHA	(5  << 16)
+# define R128_ALPHA_BLEND_SRC_DSTALPHA		(6  << 16)
+# define R128_ALPHA_BLEND_SRC_INVDSTALPHA	(7  << 16)
+# define R128_ALPHA_BLEND_SRC_DSTCOLOR		(8  << 16)
+# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR	(9  << 16)
+# define R128_ALPHA_BLEND_SRC_SAT		(10 << 16)
+# define R128_ALPHA_BLEND_SRC_BLEND		(11 << 16)
+# define R128_ALPHA_BLEND_SRC_INVBLEND		(12 << 16)
+# define R128_ALPHA_BLEND_DST_ZERO		(0  << 20)
+# define R128_ALPHA_BLEND_DST_ONE		(1  << 20)
+# define R128_ALPHA_BLEND_DST_SRCCOLOR		(2  << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCCOLOR	(3  << 20)
+# define R128_ALPHA_BLEND_DST_SRCALPHA		(4  << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCALPHA	(5  << 20)
+# define R128_ALPHA_BLEND_DST_DSTALPHA		(6  << 20)
+# define R128_ALPHA_BLEND_DST_INVDSTALPHA	(7  << 20)
+# define R128_ALPHA_BLEND_DST_DSTCOLOR		(8  << 20)
+# define R128_ALPHA_BLEND_DST_INVDSTCOLOR	(9  << 20)
+# define R128_ALPHA_TEST_NEVER			(0  << 24)
+# define R128_ALPHA_TEST_LESS			(1  << 24)
+# define R128_ALPHA_TEST_LESSEQUAL		(2  << 24)
+# define R128_ALPHA_TEST_EQUAL			(3  << 24)
+# define R128_ALPHA_TEST_GREATEREQUAL		(4  << 24)
+# define R128_ALPHA_TEST_GREATER		(5  << 24)
+# define R128_ALPHA_TEST_NEQUAL			(6  << 24)
+# define R128_ALPHA_TEST_ALWAYS			(7  << 24)
+# define R128_COMPOSITE_SHADOW_CMP_EQUAL	(0  << 28)
+# define R128_COMPOSITE_SHADOW_CMP_NEQUAL	(1  << 28)
+# define R128_COMPOSITE_SHADOW			(1  << 29)
+# define R128_TEX_MAP_ALPHA_IN_TEXTURE		(1  << 30)
+# define R128_TEX_CACHE_LINE_SIZE_8QW		(0  << 31)
+# define R128_TEX_CACHE_LINE_SIZE_4QW		(1  << 31)
+#define R128_REG_SCALE_3D_DATATYPE		0x1a20
+
+#define R128_DATATYPE_C8			2
+#define R128_DATATYPE_ARGB_1555			3
+#define R128_DATATYPE_RGB_565			4
+#define R128_DATATYPE_ARGB_8888			6
+#define R128_DATATYPE_RGB_332			7
+#define R128_DATATYPE_Y8			8
+#define R128_DATATYPE_RGB_8			9
+#define R128_DATATYPE_VYUY_422			11
+#define R128_DATATYPE_YVYU_422			12
+#define R128_DATATYPE_AYUV_444			14
+#define R128_DATATYPE_ARGB_4444			15
+
+#define R128_PM4_NONPM4				(0  << 28)
+#define R128_PM4_192PIO				(1  << 28)
+#define R128_PM4_192BM				(2  << 28)
+#define R128_PM4_128PIO_64INDBM			(3  << 28)
+#define R128_PM4_128BM_64INDBM			(4  << 28)
+#define R128_PM4_64PIO_128INDBM			(5  << 28)
+#define R128_PM4_64BM_128INDBM			(6  << 28)
+#define R128_PM4_64PIO_64VCBM_64INDBM		(7  << 28)
+#define R128_PM4_64BM_64VCBM_64INDBM		(8  << 28)
+#define R128_PM4_64PIO_64VCPIO_64INDPIO		(15 << 28)