Re: Software fallback fixes and R300 driver work

2004-09-24 Thread Brian Paul
Nicolai Haehnle wrote:
Hi,
apparently I'm the first to use a full software fallback for glClear(), as I 
ran into a few problems that the attached patch should fix:
- spantmp.h doesn't check for NULL masks
- add a WriteMonoDepthSpan function to the swrast to driver interface
- use this function to clear the depth buffer in swrast when available 
(swrast depth buffer clearing completely ignores driver functions right 
now)
Looks good.  I've checked in the patch.
-Brian

---
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
--
___
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel


Software fallback fixes and R300 driver work

2004-09-23 Thread Nicolai Haehnle
Hi,

apparently I'm the first to use a full software fallback for glClear(), as I 
ran into a few problems that the attached patch should fix:
- spantmp.h doesn't check for NULL masks
- add a WriteMonoDepthSpan function to the swrast to driver interface
- use this function to clear the depth buffer in swrast when available 
(swrast depth buffer clearing completely ignores driver functions right 
now)

I decided to take it to the next level and actually start hacking on a DRI 
driver for the R300. So far I modified the R200 driver to recognize the 
R300 family and use 100% software fallbacks in this case. I will put source 
up as soon as some rasterization is actually hardware accelerated.

One thing I noticed in the process: r200Flush() unconditionally calls 
r200EmitState(). Is this really necessary? I was assuming that glFlush() 
could be a noop when it's not preceded by any rendering commands.

cu,
Nicolai
Index: drivers/dri/common/depthtmp.h
===
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/depthtmp.h,v
retrieving revision 1.2
diff -u -p -r1.2 depthtmp.h
--- drivers/dri/common/depthtmp.h	6 Aug 2003 18:12:22 -	1.2
+++ drivers/dri/common/depthtmp.h	23 Sep 2004 23:27:25 -
@@ -64,6 +64,42 @@ static void TAG(WriteDepthSpan)( GLconte
HW_WRITE_UNLOCK();
 }
 
+static void TAG(WriteMonoDepthSpan)( GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLdepth depth,
+ const GLubyte mask[] )
+{
+   HW_WRITE_LOCK()
+  {
+	 GLint x1;
+	 GLint n1;
+	 LOCAL_DEPTH_VARS;
+
+	 y = Y_FLIP( y );
+
+	 HW_CLIPLOOP()
+	{
+	   GLint i = 0;
+	   CLIPSPAN( x, y, n, x1, n1, i );
+
+	   if ( DBG ) fprintf( stderr, %s %d..%d (x1 %d) = %u\n,
+   __FUNCTION__, (int)i, (int)n1, (int)x1, (uint)depth );
+
+	   if ( mask ) {
+		  for ( ; i  n1 ; i++, x1++ ) {
+		 if ( mask[i] ) WRITE_DEPTH( x1, y, depth );
+		  }
+	   } else {
+		  for ( ; i  n1 ; i++, x1++ ) {
+		 WRITE_DEPTH( x1, y, depth );
+		  }
+	   }
+	}
+	 HW_ENDCLIPLOOP();
+  }
+   HW_WRITE_UNLOCK();
+}
+
 static void TAG(WriteDepthPixels)( GLcontext *ctx,
    GLuint n,
    const GLint x[],
Index: drivers/dri/common/spantmp.h
===
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/common/spantmp.h,v
retrieving revision 1.2
diff -u -p -r1.2 spantmp.h
--- drivers/dri/common/spantmp.h	6 Aug 2003 18:12:22 -	1.2
+++ drivers/dri/common/spantmp.h	23 Sep 2004 23:27:25 -
@@ -123,15 +123,29 @@ static void TAG(WriteRGBAPixels)( const 
 
 	 HW_WRITE_CLIPLOOP()
 	{
-	   for (i=0;in;i++)
+	   if (mask)
 	   {
-		  if (mask[i]) {
+	  for (i=0;in;i++)
+	  {
+		 if (mask[i]) {
+		const int fy = Y_FLIP(y[i]);
+		if (CLIPPIXEL(x[i],fy))
+			   WRITE_RGBA( x[i], fy,
+   rgba[i][0], rgba[i][1],
+   rgba[i][2], rgba[i][3] );
+		 }
+	  }
+	   }
+	   else
+	   {
+	  for (i=0;in;i++)
+	  {
 		 const int fy = Y_FLIP(y[i]);
 		 if (CLIPPIXEL(x[i],fy))
 			WRITE_RGBA( x[i], fy,
 rgba[i][0], rgba[i][1],
 rgba[i][2], rgba[i][3] );
-		  }
+	  }
 	   }
 	}
 	 HW_ENDCLIPLOOP();
@@ -160,9 +174,17 @@ static void TAG(WriteMonoRGBASpan)( cons
 	{
 	   GLint i = 0;
 	   CLIPSPAN(x,y,n,x1,n1,i);
-	   for (;n10;i++,x1++,n1--)
-		  if (mask[i])
+	   if (mask)
+	   {
+	  for (;n10;i++,x1++,n1--)
+		 if (mask[i])
+		WRITE_PIXEL( x1, y, p );
+	   }
+	   else
+	   {
+	  for (;n10;i++,x1++,n1--)
 		 WRITE_PIXEL( x1, y, p );
+	   }
 	}
 	 HW_ENDCLIPLOOP();
   }
@@ -186,12 +208,23 @@ static void TAG(WriteMonoRGBAPixels)( co
 
 	 HW_WRITE_CLIPLOOP()
 	{
-	   for (i=0;in;i++)
-		  if (mask[i]) {
+	   if (mask)
+	   {
+		  for (i=0;in;i++)
+		 if (mask[i]) {
+			int fy = Y_FLIP(y[i]);
+			if (CLIPPIXEL( x[i], fy ))
+			   WRITE_PIXEL( x[i], fy, p );
+		 }
+	   }
+	   else
+	   {
+		  for (i=0;in;i++) {
 		 int fy = Y_FLIP(y[i]);
 		 if (CLIPPIXEL( x[i], fy ))
 			WRITE_PIXEL( x[i], fy, p );
 		  }
+	   }
 	}
 	 HW_ENDCLIPLOOP();
   }
@@ -238,12 +271,23 @@ static void TAG(ReadRGBAPixels)( const G
 
 	 HW_READ_CLIPLOOP()
 	{
-	   for (i=0;in;i++)
-		  if (mask[i]) {
+	   if (mask)
+	   {
+		  for (i=0;in;i++)
+		 if (mask[i]) {
+			int fy = Y_FLIP( y[i] );
+			if (CLIPPIXEL( x[i], fy ))
+			   READ_RGBA( rgba[i], x[i], fy );
+		 }
+	   }
+	   else
+	   {
+		  for (i=0;in;i++) {
 		 int fy = Y_FLIP( y[i] );
 		 if (CLIPPIXEL( x[i], fy ))
 			READ_RGBA( rgba[i], x[i], fy );
 		  }
+	   }
 	}
 	 HW_ENDCLIPLOOP();
   }
Index: swrast/s_depth.c
===
RCS file: 

Re: Software fallback fixes and R300 driver work

2004-09-23 Thread Eric Anholt
On Thu, 2004-09-23 at 18:15, Nicolai Haehnle wrote:
 One thing I noticed in the process: r200Flush() unconditionally calls 
 r200EmitState(). Is this really necessary? I was assuming that glFlush() 
 could be a noop when it's not preceded by any rendering commands.

While I suspect this would be legal, note that r200Flush is called from
FIREVERTICES, so that emit state that's happening is probably
necessary.  I had noted this with r200Clear, which depends on state
being (semi-?) current at the time of the clear ioctl, and FIREVERTICES
and the racefixes should guarantee that.

-- 
Eric Anholt[EMAIL PROTECTED]  
http://people.freebsd.org/~anholt/ [EMAIL PROTECTED]




---
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
--
___
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: Software fallback fixes and R300 driver work

2004-09-23 Thread Alex Deucher
On Fri, 24 Sep 2004 03:15:01 +0200, Nicolai Haehnle [EMAIL PROTECTED] wrote:
 Hi,
 
 apparently I'm the first to use a full software fallback for glClear(), as I
 ran into a few problems that the attached patch should fix:
 - spantmp.h doesn't check for NULL masks
 - add a WriteMonoDepthSpan function to the swrast to driver interface
 - use this function to clear the depth buffer in swrast when available
 (swrast depth buffer clearing completely ignores driver functions right
 now)
 
 I decided to take it to the next level and actually start hacking on a DRI
 driver for the R300. So far I modified the R200 driver to recognize the
 R300 family and use 100% software fallbacks in this case. I will put source
 up as soon as some rasterization is actually hardware accelerated.

If you have a 100% software driver that works that might be a good
starting point for a software DRI driver to ween ourselves off GLcore
and eventually allow for accelerated indirect rendering.

Alex

 
 One thing I noticed in the process: r200Flush() unconditionally calls
 r200EmitState(). Is this really necessary? I was assuming that glFlush()
 could be a noop when it's not preceded by any rendering commands.
 
 cu,
 Nicolai
 
 
 



---
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
--
___
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel