On Fri, 7 Feb 2003, Keith Whitwell wrote:

> >> I don't have a local copy of the mesa-4.0.4 branch.  Could somebody 
> >> commit this change to that tree?  It's a pretty easy fix & should make 
> >> Linus happy. :)
> > 
> > 
> > I'll do it.
> 
> Actually, I take that back - I don't have an r200 handy to test & the diff 
> didn't apply cleanly enough to "wing it"...
> 
> Anyone else?
> 
> Keith

Here's a hand-merged diff against mesa-4-0-4-branch.  How does this look?

-- 
Leif Delgass 
http://www.retinalburn.net
Index: r200_texstate.c
===================================================================
RCS file: /cvsroot/dri/xc/xc/lib/GL/mesa/src/drv/r200/r200_texstate.c,v
retrieving revision 1.7
diff -u -r1.7 r200_texstate.c
--- r200_texstate.c     5 Nov 2002 21:19:50 -0000       1.7
+++ r200_texstate.c     7 Feb 2003 21:41:52 -0000
@@ -47,6 +47,7 @@
 #include "mmath.h"
 #include "simple_list.h"
 #include "texformat.h"
+#include "enums.h"
 
 
 static void r200SetTexImages( r200ContextPtr rmesa,
@@ -702,16 +703,19 @@
 {
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   const struct gl_texture_object *tObj = texUnit->_Current;
+   const GLenum format = tObj->Image[tObj->BaseLevel]->Format;
    GLuint color_combine, alpha_combine;
    GLuint color_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2];
    GLuint alpha_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2];
 
    if ( R200_DEBUG & DEBUG_TEXTURE ) {
-      fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, ctx, unit );
+      fprintf( stderr, "%s( %p, %d ) format=%s\n", __FUNCTION__,
+              ctx, unit, _mesa_lookup_enum_by_nr( format ) );
    }
 
    /* Set the texture environment state.  Isn't this nice and clean?
-    * The R200 will automagically set the texture alpha to 0xff when
+    * The chip will automagically set the texture alpha to 0xff when
     * the texture format does not include an alpha component.  This
     * reduces the amount of special-casing we have to do, alpha-only
     * textures being a notable exception.
@@ -729,6 +733,8 @@
       const GLenum format = tObj->Image[tObj->BaseLevel]->Format;
       GLuint color_arg[3], alpha_arg[3];
       GLuint i, numColorArgs = 0, numAlphaArgs = 0;
+      GLuint RGBshift = texUnit->CombineScaleShiftRGB;
+      GLuint Ashift = texUnit->CombineScaleShiftA;
 
       switch ( texUnit->EnvMode ) {
       case GL_REPLACE:
@@ -867,6 +873,8 @@
         case GL_SUBTRACT:
         case GL_DOT3_RGB:
         case GL_DOT3_RGBA:
+        case GL_DOT3_RGB_EXT:
+        case GL_DOT3_RGBA_EXT:
            numColorArgs = 2;
            break;
         case GL_INTERPOLATE:
@@ -880,10 +888,10 @@
         case GL_REPLACE:
            numAlphaArgs = 1;
            break;
-        case GL_SUBTRACT:
         case GL_MODULATE:
         case GL_ADD:
         case GL_ADD_SIGNED:
+        case GL_SUBTRACT:
            numAlphaArgs = 2;
            break;
         case GL_INTERPOLATE:
@@ -969,14 +977,6 @@
            R200_COLOR_ARG( 0, A );
            R200_COLOR_ARG( 1, C );
            break;
-        case GL_SUBTRACT:
-           color_combine = (R200_TXC_ARG_B_ZERO |
-                            R200_TXC_COMP_ARG_B | 
-                            R200_TXC_NEG_ARG_C |
-                            R200_TXC_OP_MADD);
-           R200_COLOR_ARG( 0, A );
-           R200_COLOR_ARG( 1, C );
-           break;
         case GL_ADD_SIGNED:
            color_combine = (R200_TXC_ARG_B_ZERO |
                             R200_TXC_COMP_ARG_B |
@@ -985,16 +985,46 @@
            R200_COLOR_ARG( 0, A );
            R200_COLOR_ARG( 1, C );
            break;
+        case GL_SUBTRACT:
+           color_combine = (R200_TXC_ARG_B_ZERO |
+                            R200_TXC_COMP_ARG_B | 
+                            R200_TXC_NEG_ARG_C |
+                            R200_TXC_OP_MADD);
+           R200_COLOR_ARG( 0, A );
+           R200_COLOR_ARG( 1, C );
+           break;
         case GL_INTERPOLATE:
            color_combine = (R200_TXC_OP_LERP);
            R200_COLOR_ARG( 0, B );
            R200_COLOR_ARG( 1, A );
            R200_COLOR_ARG( 2, C );
            break;
+
+        case GL_DOT3_RGB_EXT:
+        case GL_DOT3_RGBA_EXT:
+           RGBshift = 0;
+           Ashift = 0;
+           /* FALLTHROUGH */
+
         case GL_DOT3_RGB:
         case GL_DOT3_RGBA:
+           /* DOT3 works differently on R200 than on R100.  On R100, just
+            * setting the DOT3 mode did everything for you.  On R200, the
+            * driver has to enable the biasing (the -0.5 in the combine
+            * equation), and it has add the 4x scale factor.  The hardware
+            * only supports up to 8x in the post filter, so 2x part of it
+            * happens on the inputs going into the combiner.
+            */
+
+           RGBshift++;
+           Ashift = RGBshift;
+
            color_combine = (R200_TXC_ARG_C_ZERO |
-                            R200_TXC_OP_DOT3);
+                            R200_TXC_OP_DOT3 |
+                            R200_TXC_BIAS_ARG_A |
+                            R200_TXC_BIAS_ARG_B |
+                            R200_TXC_SCALE_ARG_A |
+                            R200_TXC_SCALE_ARG_B);
            R200_COLOR_ARG( 0, A );
            R200_COLOR_ARG( 1, B );
            break;
@@ -1022,19 +1052,19 @@
            R200_ALPHA_ARG( 0, A );
            R200_ALPHA_ARG( 1, C );
            break;
-        case GL_SUBTRACT:
+        case GL_ADD_SIGNED:
            alpha_combine = (R200_TXA_ARG_B_ZERO |
                             R200_TXC_COMP_ARG_B |
-                            R200_TXC_NEG_ARG_C |
-                            R200_TXA_OP_MADD);
+                            R200_TXC_BIAS_ARG_C |      /* new */
+                            R200_TXA_OP_MADD); /* was ADDSIGNED */
            R200_ALPHA_ARG( 0, A );
            R200_ALPHA_ARG( 1, C );
            break;
-        case GL_ADD_SIGNED:
+        case GL_SUBTRACT:
            alpha_combine = (R200_TXA_ARG_B_ZERO |
                             R200_TXC_COMP_ARG_B |
-                            R200_TXC_BIAS_ARG_C |      /* new */
-                            R200_TXA_OP_MADD); /* was ADDSIGNED */
+                            R200_TXC_NEG_ARG_C |
+                            R200_TXA_OP_MADD);
            R200_ALPHA_ARG( 0, A );
            R200_ALPHA_ARG( 1, C );
            break;
@@ -1048,28 +1078,20 @@
            return;
         }
 
-        if ( texUnit->CombineModeRGB == GL_DOT3_RGB ) {
+        if ( (texUnit->CombineModeRGB == GL_DOT3_RGB_EXT)
+             || (texUnit->CombineModeRGB == GL_DOT3_RGB) ) {
            alpha_combine |= R200_TXA_DOT_ALPHA;
         }
 
         /* Step 3:
-         * Apply the scale factor.  The EXT extension has a somewhat
-         * unnecessary restriction that the scale must be 4x.  The ARB
-         * extension will likely drop this and we can just apply the
-         * scale factors regardless.
+         * Apply the scale factor.  The EXT version of the DOT3 extension does
+         * not support the scale factor, but the ARB version (and the version in
+         * OpenGL 1.3) does.
          */
         color_scale &= ~R200_TXC_SCALE_MASK;
         alpha_scale &= ~R200_TXA_SCALE_MASK;
-        if ( texUnit->CombineModeRGB != GL_DOT3_RGB &&
-             texUnit->CombineModeRGB != GL_DOT3_RGBA ) {
-           color_scale |= texUnit->CombineScaleShiftRGB<< R200_TXC_SCALE_SHIFT;
-           alpha_scale |= texUnit->CombineScaleShiftA << R200_TXA_SCALE_SHIFT;
-        }
-        else
-        {
-           color_scale |= R200_TXC_SCALE_4X;
-           alpha_scale |= R200_TXA_SCALE_4X;
-        }
+        color_scale |= (RGBshift << R200_TXC_SCALE_SHIFT);
+        alpha_scale |= (Ashift   << R200_TXA_SCALE_SHIFT);
 
         /* All done!
          */

Reply via email to