Hi,

There is disagreement about the meaning of the CLIPSPAN _n parameter in CVS.

The drivers I have looked at and drivers/dri/common/spantmp.h treat _n as 
the number of pixels in the span after clipping.
depthtmp.h and stenciltmp.h treat _n as the end+1 x coordinate of the span.

This inconsistency leads to artifacts when software fallbacks are hit while 
clipping is used, especially with partially obscured clients. The attached 
patch should fix these artifacts by changing depthtmp.h and stenciltmp.h 
appropriately.

cu,
Nicolai
Index: drivers/dri/common/depthtmp.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/depthtmp.h,v
retrieving revision 1.5
diff -u -p -b -r1.5 depthtmp.h
--- drivers/dri/common/depthtmp.h	8 Oct 2004 22:21:09 -0000	1.5
+++ drivers/dri/common/depthtmp.h	15 Oct 2004 19:48:14 -0000
@@ -45,15 +45,15 @@ static void TAG(WriteDepthSpan)( GLconte
 	       GLint i = 0;
 	       CLIPSPAN( x, y, n, x1, n1, i );
 
-	       if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
-				   (int)i, (int)n1, (int)x1 );
+	       if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d) (mask %p)\n",
+				   (int)i, (int)n1, (int)x1, mask );
 
 	       if ( mask ) {
-		  for ( ; i < n1 ; i++, x1++ ) {
+		  for ( ; n1>0 ; i++, x1++, n1-- ) {
 		     if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] );
 		  }
 	       } else {
-		  for ( ; i < n1 ; i++, x1++ ) {
+		  for ( ; n1>0 ; i++, x1++, n1-- ) {
 		     WRITE_DEPTH( x1, y, depth[i] );
 		  }
 	       }
@@ -87,11 +87,11 @@ static void TAG(WriteMonoDepthSpan)( GLc
 				   __FUNCTION__, (int)i, (int)n1, (int)x1, (GLuint)depth );
 
 	       if ( mask ) {
-		  for ( ; i < n1 ; i++, x1++ ) {
+		  for ( ; n1>0 ; i++, x1++, n1-- ) {
 		     if ( mask[i] ) WRITE_DEPTH( x1, y, depth );
 		  }
 	       } else {
-		  for ( ; i < n1 ; i++, x1++ ) {
+		  for ( ; n1>0 ; x1++, n1-- ) {
 		     WRITE_DEPTH( x1, y, depth );
 		  }
 	       }
@@ -162,8 +162,9 @@ static void TAG(ReadDepthSpan)( GLcontex
 	    {
 	       GLint i = 0;
 	       CLIPSPAN( x, y, n, x1, n1, i );
-	       for ( ; i < n1 ; i++ )
-		  READ_DEPTH( depth[i], (x1+i), y );
+	       for ( ; n1>0 ; i++, n1-- ) {
+		  READ_DEPTH( depth[i], x+i, y );
+	       }
 	    }
 	 HW_ENDCLIPLOOP();
 #endif
Index: drivers/dri/common/stenciltmp.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/stenciltmp.h,v
retrieving revision 1.2
diff -u -p -b -r1.2 stenciltmp.h
--- drivers/dri/common/stenciltmp.h	6 Aug 2003 18:12:22 -0000	1.2
+++ drivers/dri/common/stenciltmp.h	15 Oct 2004 19:48:15 -0000
@@ -41,13 +41,13 @@ static void TAG(WriteStencilSpan)( GLcon
 
 	       if (mask)
 	       {
-		  for (;i<n1;i++,x1++)
+		  for (;n1>0;i++,x1++,n1--)
 		     if (mask[i])
 			WRITE_STENCIL( x1, y, stencil[i] );
 	       }
 	       else
 	       {
-		  for (;i<n1;i++,x1++)
+		  for (;n1>0;i++,x1++,n1--)
 		     WRITE_STENCIL( x1, y, stencil[i] );
 	       }
 	    }
@@ -107,8 +107,8 @@ static void TAG(ReadStencilSpan)( GLcont
 	    {
 	       GLint i = 0;
 	       CLIPSPAN(x,y,n,x1,n1,i);
-	       for (;i<n1;i++)
-		  READ_STENCIL( stencil[i], (x1+i), y );
+	       for (;n1>0;i++,n1--)
+		  READ_STENCIL( stencil[i], (x+i), y );
 	    }
 	 HW_ENDCLIPLOOP();
       }

Attachment: pgpHBp7HXFaCC.pgp
Description: PGP signature

Reply via email to