separate blend equation / function on r200

2004-05-14 Thread Roland Scheidegger
Ok, here's a patch to enable separate blend function / equation on r200, 
as well as fix glBlendColor. It needs drm changes, I've tried to make it 
backward/forward compatible in all ways, except the driver will not 
build with old drm sources (so this needs to be applied first, could 
someone do this for me if the patch looks ok? I don't have drm/dri write 
access nor do I usually need it.)

A couple of comments though:
- not sure if the radeon_common.h patch for dri is needed. The packets 
defined there are exactly the same as in radeon_drm.h, which I consider 
not a good idea. But if it's doubled, at least keep it in sync...
- drm changes are just a bunch of #defines, and a version number bump. I 
think the driver date always stays the same?

Compatiblity to old drm is achieved with a bunch of ifs. If you think 
this is too ugly, I'm open for other suggestions ;-). But it didn't seem 
like that much of a headache which would warrant ditching compatiblity 
to old drm neither.
Also, if old drm is used, glBlendColor will silently fail (that's 
already the case up till now), so will the glBlendSeparate functions if 
you use different RGB and alpha factors/equations (extensions are not 
announced, but you could still use them, no error will be generated).

Also, in case of color blending, always separate blending 
functions/equations are used for the chip. I think it might be possible 
to only set the CBLENDCNTL register if the factors/equations are the 
same and not enable seperate_alpha, but this looked like more complex 
control code without any benefits. Unless, of course, separate blending 
has a performance hit, I assumed no but haven't measured it. Is there a 
good demo/benchmark somewhere which would show such a hit (i.e. lots of 
blending, but not much else done)?

Testing seemed to show the new extensions work, though I couldn't find a 
good test. Mesa lacks a test for these extensions (as well as for 
blendColor).

Roland
Index: r200_context.c
===
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_context.c,v
retrieving revision 1.23
diff -u -r1.23 r200_context.c
--- r200_context.c  29 Apr 2004 12:23:41 -  1.23
+++ r200_context.c  14 May 2004 17:04:08 -
@@ -403,5 +403,9 @@
if (rmesa->r200Screen->drmSupportsCubeMaps)
   _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
+   if (rmesa->r200Screen->drmSupportsBlendColor) {
+  _mesa_enable_extension( ctx, "GL_EXT_blend_equation_separate" );
+  _mesa_enable_extension( ctx, "GL_EXT_blend_func_separate" );
+   }

 #if 0
r200InitDriverFuncs( ctx );
Index: r200_context.h
===
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_context.h,v
retrieving revision 1.15
diff -u -r1.15 r200_context.h
--- r200_context.h  5 May 2004 20:16:17 -   1.15
+++ r200_context.h  14 May 2004 17:04:11 -
@@ -213,7 +213,12 @@
 #define CTX_RB3D_COLOROFFSET  11
 #define CTX_CMD_2 12 /* why */
 #define CTX_RB3D_COLORPITCH   13 /* why */
-#define CTX_STATE_SIZE14
+#define CTX_STATE_SIZE_OLDDRM 14
+#define CTX_CMD_3 14
+#define CTX_RB3D_BLENDCOLOR   15
+#define CTX_RB3D_ABLENDCNTL   16
+#define CTX_RB3D_CBLENDCNTL   17
+#define CTX_STATE_SIZE_NEWDRM 18
 
 #define SET_CMD_0   0
 #define SET_SE_CNTL 1
Index: r200_reg.h
===
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_reg.h,v
retrieving revision 1.4
diff -u -r1.4 r200_reg.h
--- r200_reg.h  14 May 2004 13:01:08 -  1.4
+++ r200_reg.h  14 May 2004 17:04:20 -
@@ -1307,6 +1307,7 @@
 #define R200_PP_TXABLEND_70x2f78
 #define R200_PP_TXABLEND2_7   0x2f7c
 /* gap */
+#define R200_RB3D_BLENDCOLOR   0x3218 /* ARGB  */
 #define R200_RB3D_ABLENDCNTL   0x321C /* see BLENDCTL */
 #define R200_RB3D_CBLENDCNTL   0x3220 /* see BLENDCTL */
 
Index: r200_screen.c
===
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_screen.c,v
retrieving revision 1.18
diff -u -r1.18 r200_screen.c
--- r200_screen.c   29 Apr 2004 12:23:41 -  1.18
+++ r200_screen.c   14 May 2004 17:04:23 -
@@ -351,6 +352,10 @@
 
 /* Check if kernel module is new enough to support cube maps */
 screen->drmSupportsCubeMaps = (sPriv->drmMinor >= 7);
+/* Check if kernel module is new enough to support blend color and
+separate blend functions/eqations */
+ screen->drmSupportsBlendColor = (sPriv->drmMinor >= 11);
+
   }
}
 
Index: r200_screen.h
===
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_screen.h,v
retrieving revision 1.7
diff -u -r1.7 r200_screen.h
--- r200_screen.h  

Re: separate blend equation / function on r200

2004-05-18 Thread Roland Scheidegger
Roland Scheidegger wrote:
Ok, here's a patch to enable separate blend function / equation on r200, 
as well as fix glBlendColor. It needs drm changes, I've tried to make it 
backward/forward compatible in all ways, except the driver will not 
build with old drm sources (so this needs to be applied first),
I've commited the changes to the drm and dri tree (still not sure if the 
packet defines really should live in the dri tree, radeon_common.h, too, 
but I didn't feel like ripping out all the duplicated defines).
Since I needed to up the minor version of the radeon drm, if someone 
else has radeon drm changes which require a new minor version, now would 
probably be a good time to add them (maybe some more tfactor registers 
or something like that? The driver seems to lack some as far as I can 
see...), otherwise you'd just need to update to minor version again later...

I haven't checked in the changes to the mesa tree yet, but soon, so you 
have a day or two left to get a new drm version ;-).

Roland
---
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
--
___
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel