This patch enables triangle strips and fans support on G400.
- New drm should be compatible with old userspace and vice versa.
- I threw that cull_dualtex stuff out. I moved the spcial case to
EmitHWStateLocked() and it's only used when an old drm is detected. It
is needed because the old drm swaps the WARPs with dualtex for some
reason. I also changed the drm's WACCEPTSEQ dualtex value to 0x1c000000
from 0x1e000000. I don't think there's any need to touch seqlen. Only
wfirsttag needs to be toggled.
- MGA_DEBUG=verb now prints the hw primitive type. It's a bit ugly due to
the FINISH macro I added which restores the primitive to GL_TRIANGLES.
Maybe there's a better way to restore the primitive for the normal
pipeline stage...
- I bumped the drm version to 3.2.0 and used that to detect wacceptseq
ioctl support. What's the guideline with this sort of thing?
- I changed the dualtex fan WACCEPTSEQ value to the one used in the WARP
DDK. I'm not entirely sure about this but I suspect the change was needed
due to the cull_dualtex stuff. I only have single tex + fan apps so I'll
have to write a test for this...
--
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
Index: lib/GL/mesa/src/drv/mga/mga_xmesa.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v
retrieving revision 1.54
diff -u -r1.54 mga_xmesa.c
--- lib/GL/mesa/src/drv/mga/mga_xmesa.c 25 Jun 2003 17:13:46 -0000 1.54
+++ lib/GL/mesa/src/drv/mga/mga_xmesa.c 29 Jul 2003 15:37:51 -0000
@@ -99,6 +99,8 @@
return GL_FALSE;
}
}
+
+ mgaScreen->drm_wacceptseq = (sPriv->drmMajor > 3) || ((sPriv->drmMajor == 3) &&
(sPriv->drmMinor > 1));
mgaScreen->linecomp_sane = (sPriv->ddxMajor > 1) || (sPriv->ddxMinor > 1)
|| ((sPriv->ddxMinor == 1) && (sPriv->ddxPatch > 0));
@@ -245,9 +247,8 @@
&_tnl_texgen_stage,
&_tnl_texture_transform_stage,
/* REMOVE: point attenuation stage */
-#if 0
+#if 1
&_mga_render_stage, /* ADD: unclipped rastersetup-to-dma */
- /* Need new ioctl for wacceptseq */
#endif
&_tnl_render_stage,
0,
Index: lib/GL/mesa/src/drv/mga/mga_xmesa.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h,v
retrieving revision 1.23
diff -u -r1.23 mga_xmesa.h
--- lib/GL/mesa/src/drv/mga/mga_xmesa.h 30 Apr 2003 01:50:40 -0000 1.23
+++ lib/GL/mesa/src/drv/mga/mga_xmesa.h 29 Jul 2003 15:37:51 -0000
@@ -50,6 +50,8 @@
GLboolean linecomp_sane; /* GL_TRUE if line comp. programmed correctly
* by the DDX driver.
*/
+ GLboolean drm_wacceptseq; /* GL_TRUE if drm supports wacceptseq ioctl.
+ */
unsigned int mAccess;
Index: lib/GL/mesa/src/drv/mga/mgacontext.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/mga/mgacontext.h,v
retrieving revision 1.26
diff -u -r1.26 mgacontext.h
--- lib/GL/mesa/src/drv/mga/mgacontext.h 22 Jul 2003 04:54:31 -0000 1.26
+++ lib/GL/mesa/src/drv/mga/mgacontext.h 29 Jul 2003 15:37:51 -0000
@@ -153,7 +153,6 @@
struct mga_hw_state {
GLuint specen;
GLuint cull;
- GLuint cull_dualtex;
GLuint stencil;
GLuint stencilctl;
GLuint stencil_enable;
@@ -347,7 +346,7 @@
#define MGA_WA_TRIANGLES 0x18000000
#define MGA_WA_TRISTRIP_T0 0x02010200
#define MGA_WA_TRIFAN_T0 0x01000408
-#define MGA_WA_TRISTRIP_T0T1 0x02010400
+#define MGA_WA_TRISTRIP_T0T1 0x02020400
#define MGA_WA_TRIFAN_T0T1 0x01000810
#endif
Index: lib/GL/mesa/src/drv/mga/mgaioctl.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c,v
retrieving revision 1.37
diff -u -r1.37 mgaioctl.c
--- lib/GL/mesa/src/drv/mga/mgaioctl.c 21 May 2003 17:32:07 -0000 1.37
+++ lib/GL/mesa/src/drv/mga/mgaioctl.c 29 Jul 2003 15:37:52 -0000
@@ -459,6 +459,7 @@
int nbox = mmesa->numClipRects;
drmBufPtr buffer = mmesa->vertex_dma_buffer;
drmMGAVertex vertex;
+ drmMGAWacceptSeq wacceptseq;
int i;
mmesa->vertex_dma_buffer = 0;
@@ -493,6 +494,12 @@
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "Firing vertex -- case a nbox %d\n", nbox);
+ if (mmesa->mgaScreen->drm_wacceptseq && MGA_IS_G400(mmesa)) {
+ wacceptseq.wacceptseq = mmesa->hw_primitive;
+ drmCommandWrite( mmesa->driFd, DRM_MGA_WACCEPTSEQ,
+ &wacceptseq, sizeof(drmMGAWacceptSeq) );
+ }
+
vertex.idx = buffer->idx;
vertex.used = buffer->used;
vertex.discard = 1;
@@ -539,6 +546,12 @@
discard = 1;
mmesa->sarea->dirty |= MGA_UPLOAD_CLIPRECTS;
+
+ if (mmesa->mgaScreen->drm_wacceptseq && MGA_IS_G400(mmesa)) {
+ wacceptseq.wacceptseq = mmesa->hw_primitive;
+ drmCommandWrite( mmesa->driFd, DRM_MGA_WACCEPTSEQ,
+ &wacceptseq, sizeof(drmMGAWacceptSeq) );
+ }
vertex.idx = buffer->idx;
vertex.used = buffer->used;
Index: lib/GL/mesa/src/drv/mga/mgarender.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/mga/mgarender.c,v
retrieving revision 1.9
diff -u -r1.9 mgarender.c
--- lib/GL/mesa/src/drv/mga/mgarender.c 25 Mar 2003 13:59:46 -0000 1.9
+++ lib/GL/mesa/src/drv/mga/mgarender.c 29 Jul 2003 15:37:52 -0000
@@ -110,10 +110,16 @@
FLUSH_BATCH(mmesa); \
mgaDmaPrimitive( ctx, prim ); \
} while (0)
+#define FINISH do { \
+ FLUSH_BATCH(mmesa); \
+ mgaDmaPrimitive( ctx, GL_TRIANGLES ); \
+} while (0)
#define NEW_PRIMITIVE() FLUSH_BATCH( mmesa )
#define NEW_BUFFER() FLUSH_BATCH( mmesa )
#define GET_CURRENT_VB_MAX_VERTS() \
- 0 /* fix me */
+ (mmesa->vertex_dma_buffer ?
+ (mmesa->vertex_dma_buffer->total - mmesa->vertex_dma_buffer->used) /
+ (mmesa->vertex_size * 4) : 0)
#define GET_SUBSEQUENT_VB_MAX_VERTS() \
MGA_BUFFER_SIZE / (mmesa->vertex_size * 4)
#define EMIT_VERTS( ctx, j, nr ) \
@@ -140,7 +146,8 @@
/* Don't handle clipping or indexed vertices or vertex manipulations.
*/
- if (VB->ClipOrMask || mmesa->RenderIndex != 0 || VB->Elts) {
+ if (!mmesa->mgaScreen->drm_wacceptseq || MGA_IS_G200(mmesa) ||
+ VB->ClipOrMask || mmesa->RenderIndex != 0 || VB->Elts) {
return GL_TRUE;
}
Index: lib/GL/mesa/src/drv/mga/mgastate.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/mga/mgastate.c,v
retrieving revision 1.41
diff -u -r1.41 mgastate.c
--- lib/GL/mesa/src/drv/mga/mgastate.c 23 Jul 2003 13:40:07 -0000 1.41
+++ lib/GL/mesa/src/drv/mga/mgastate.c 29 Jul 2003 15:37:53 -0000
@@ -355,13 +355,9 @@
if (ctx->Polygon.FrontFace != GL_CCW)
mmesa->hw.cull ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
-
- mmesa->hw.cull_dualtex = mmesa->hw.cull ^
- (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* warp bug? */
}
else {
mmesa->hw.cull = _CULL_DISABLE;
- mmesa->hw.cull_dualtex = _CULL_DISABLE;
}
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
@@ -993,13 +989,13 @@
if (mmesa->dirty & MGA_UPLOAD_CONTEXT) {
mmesa->setup.wflag = _CULL_DISABLE;
if (mmesa->raster_primitive == GL_TRIANGLES) {
- if ((ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
- ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT)) {
- mmesa->setup.wflag = mmesa->hw.cull_dualtex;
- }
- else {
- mmesa->setup.wflag = mmesa->hw.cull;
- }
+ mmesa->setup.wflag = mmesa->hw.cull;
+
+ if (!mmesa->mgaScreen->drm_wacceptseq && mmesa->hw.cull &&
+ ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
+ ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) {
+ mmesa->setup.wflag ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
+ }
}
mmesa->setup.stencil = mmesa->hw.stencil
@@ -1064,7 +1060,6 @@
}
if (mmesa->dirty & MGA_UPLOAD_PIPE) {
-/* mmesa->sarea->wacceptseq = mmesa->hw_primitive; */
mmesa->sarea->WarpPipe = mmesa->vertex_format;
mmesa->sarea->vertsize = mmesa->vertex_size;
}
@@ -1193,8 +1188,7 @@
mmesa->hw.stencilctl = SC_smode_salways | SC_sfailop_keep
| SC_szfailop_keep | SC_szpassop_keep;
mmesa->hw.stencil_enable = 0;
- mmesa->hw.cull = _CULL_NEGATIVE;
- mmesa->hw.cull_dualtex = _CULL_POSITIVE;
+ mmesa->hw.cull = _CULL_DISABLE;
mmesa->hw.specen = 0;
mmesa->setup.dwgctl = (DC_opcod_trap |
Index: lib/GL/mesa/src/drv/mga/mgatris.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/mga/mgatris.c,v
retrieving revision 1.28
diff -u -r1.28 mgatris.c
--- lib/GL/mesa/src/drv/mga/mgatris.c 26 Jul 2003 19:50:53 -0000 1.28
+++ lib/GL/mesa/src/drv/mga/mgatris.c 29 Jul 2003 15:37:54 -0000
@@ -27,6 +27,7 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatris.c,v 1.10 2002/10/30 12:51:36 alanh
Exp $ */
#include "mtypes.h"
+#include "enums.h"
#include "macros.h"
#include "colormac.h"
#include "swrast/swrast.h"
@@ -769,6 +770,32 @@
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ if (MGA_DEBUG & DEBUG_VERBOSE_MSG) {
+ /* Prints reduced prim, and hw prim */
+ char *prim_name = "Unknown";
+ switch(hwprim) {
+ case MGA_WA_TRIANGLES:
+ prim_name = "TriList";
+ break;
+ case MGA_WA_TRISTRIP_T0:
+ prim_name = "TriStrip T0";
+ break;
+ case MGA_WA_TRISTRIP_T0T1:
+ prim_name = "TriStrip T0T1";
+ break;
+ case MGA_WA_TRIFAN_T0:
+ prim_name = "TriFan T0";
+ break;
+ case MGA_WA_TRIFAN_T0T1:
+ prim_name = "TriFan T0T1";
+ break;
+ }
+ fprintf(stderr, "%s : prim(%s), hwprim(%s)\n",
+ __FUNCTION__,
+ _mesa_lookup_enum_by_nr(prim),
+ prim_name);
+ }
+
FLUSH_BATCH( mmesa );
/* Update culling */
@@ -776,8 +803,7 @@
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
mmesa->raster_primitive = prim;
-/* mmesa->hw_primitive = hwprim; */
- mmesa->hw_primitive = MGA_WA_TRIANGLES; /* disable mgarender.c for now */
+ mmesa->hw_primitive = hwprim;
if (ctx->Polygon.StippleFlag && mmesa->haveHwStipple)
{
Index: programs/Xserver/hw/xfree86/drivers/mga/mga_common.h
===================================================================
RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_common.h,v
retrieving revision 1.3
diff -u -r1.3 mga_common.h
--- programs/Xserver/hw/xfree86/drivers/mga/mga_common.h 31 Oct 2002 00:49:55
-0000 1.3
+++ programs/Xserver/hw/xfree86/drivers/mga/mga_common.h 29 Jul 2003 15:37:57
-0000
@@ -59,6 +59,7 @@
#define DRM_MGA_ILOAD 0x07
#define DRM_MGA_BLIT 0x08
#define DRM_MGA_GETPARAM 0x09
+#define DRM_MGA_WACCEPTSEQ 0x0A
typedef struct {
enum {
@@ -148,5 +149,9 @@
int param;
int *value;
} drmMGAGetParam;
+
+typedef struct {
+ unsigned int wacceptseq;
+} drmMGAWacceptSeq;
#endif
Index: programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga.h
===================================================================
RCS file:
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga.h,v
retrieving revision 1.4
diff -u -r1.4 mga.h
--- programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga.h 26 Apr 2003
22:28:54 -0000 1.4
+++ programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga.h 29 Jul 2003
15:37:59 -0000
@@ -48,7 +48,7 @@
#define DRIVER_DATE "20021029"
#define DRIVER_MAJOR 3
-#define DRIVER_MINOR 1
+#define DRIVER_MINOR 2
#define DRIVER_PATCHLEVEL 0
#define DRIVER_IOCTLS \
@@ -62,7 +62,8 @@
[DRM_IOCTL_NR(DRM_IOCTL_MGA_INDICES)] = { mga_dma_indices, 1, 0 }, \
[DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)] = { mga_dma_iload, 1, 0 }, \
[DRM_IOCTL_NR(DRM_IOCTL_MGA_BLIT)] = { mga_dma_blit, 1, 0 }, \
- [DRM_IOCTL_NR(DRM_IOCTL_MGA_GETPARAM)]= { mga_getparam, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_GETPARAM)]= { mga_getparam, 1, 0 }, \
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_WACCEPTSEQ)]= { mga_wacceptseq, 1, 0 },
#define __HAVE_COUNTERS 3
#define __HAVE_COUNTER6 _DRM_STAT_IRQ
Index: programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drm.h
===================================================================
RCS file:
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drm.h,v
retrieving revision 1.4
diff -u -r1.4 mga_drm.h
--- programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drm.h 30 Oct 2002
06:10:33 -0000 1.4
+++ programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drm.h 29 Jul 2003
15:38:00 -0000
@@ -240,6 +240,7 @@
#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x47, drm_mga_iload_t)
#define DRM_IOCTL_MGA_BLIT DRM_IOW( 0x48, drm_mga_blit_t)
#define DRM_IOCTL_MGA_GETPARAM DRM_IOWR(0x49, drm_mga_getparam_t)
+#define DRM_IOCTL_MGA_WACCEPTSEQ DRM_IOWR(0x4A, drm_mga_wacceptseq_t)
typedef struct _drm_mga_warp_index {
int installed;
@@ -332,5 +333,9 @@
int param;
int *value;
} drm_mga_getparam_t;
+
+typedef struct drm_mga_wacceptseq {
+ unsigned int wacceptseq;
+} drm_mga_wacceptseq_t;
#endif
Index: programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h
===================================================================
RCS file:
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h,v
retrieving revision 1.9
diff -u -r1.9 mga_drv.h
--- programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h 16 May 2003
23:41:27 -0000 1.9
+++ programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_drv.h 29 Jul 2003
15:38:01 -0000
@@ -76,6 +76,7 @@
u32 clear_cmd;
u32 maccess;
+ u32 wacceptseq;
unsigned int fb_cpp;
unsigned int front_offset;
@@ -126,6 +127,7 @@
extern int mga_dma_iload( DRM_IOCTL_ARGS );
extern int mga_dma_blit( DRM_IOCTL_ARGS );
extern int mga_getparam( DRM_IOCTL_ARGS );
+extern int mga_wacceptseq( DRM_IOCTL_ARGS );
/* mga_warp.c */
extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
Index: programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c
===================================================================
RCS file:
/cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c,v
retrieving revision 1.7
diff -u -r1.7 mga_state.c
--- programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c 28 Mar
2003 14:27:35 -0000 1.7
+++ programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/mga_state.c 29 Jul
2003 15:38:02 -0000
@@ -296,7 +296,7 @@
DMA_BLOCK( MGA_WACCEPTSEQ, 0x00000000,
MGA_WACCEPTSEQ, 0x00000000,
MGA_WACCEPTSEQ, 0x00000000,
- MGA_WACCEPTSEQ, 0x1e000000 );
+ MGA_WACCEPTSEQ, 0x1c000000 );
} else {
if ( dev_priv->warp_pipe & MGA_T2 ) {
/* Flush the WARP pipe */
@@ -686,7 +686,14 @@
&sarea_priv->boxes[i] );
}
- BEGIN_DMA( 1 );
+ BEGIN_DMA( 2 );
+
+ if (dev_priv->wacceptseq) {
+ DMA_BLOCK( MGA_WACCEPTSEQ, 0x00000000,
+ MGA_WACCEPTSEQ, 0x00000000,
+ MGA_WACCEPTSEQ, 0x00000000,
+ MGA_WACCEPTSEQ, dev_priv->wacceptseq );
+ }
DMA_BLOCK( MGA_DMAPAD, 0x00000000,
MGA_DMAPAD, 0x00000000,
@@ -1106,5 +1113,23 @@
return DRM_ERR(EFAULT);
}
+ return 0;
+}
+
+int mga_wacceptseq( DRM_IOCTL_ARGS )
+{
+ DRM_DEVICE;
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_wacceptseq_t wacceptseq;
+
+ LOCK_TEST_WITH_RETURN( dev, filp );
+
+ DRM_COPY_FROM_USER_IOCTL( wacceptseq, (drm_mga_wacceptseq_t *)data,
+ sizeof(wacceptseq) );
+
+ WRAP_TEST_WITH_RETURN( dev_priv );
+
+ dev_priv->wacceptseq = wacceptseq.wacceptseq;
+
return 0;
}