reverted TMUs for proper multitexturing
authorDaniel Borca <dborca@users.sourceforge.net>
Tue, 23 Dec 2003 14:11:22 +0000 (14:11 +0000)
committerDaniel Borca <dborca@users.sourceforge.net>
Tue, 23 Dec 2003 14:11:22 +0000 (14:11 +0000)
progs/samples/Makefile.DJ
progs/samples/Makefile.mgw
src/mesa/drivers/glide/fxsetup.c
src/mesa/drivers/glide/fxsetup.h
src/mesa/drivers/glide/fxvb.c

index 2f0f687587b9464fe95df077b4eb44ccccda2dea..9b1055ce7333175d187c712b14e69405b08a97f8 100644 (file)
@@ -20,7 +20,7 @@
 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-# DOS/DJGPP samples makefile v1.4 for Mesa
+# DOS/DJGPP samples makefile v1.5 for Mesa
 #
 #  Copyright (C) 2002 - Borca Daniel
 #  Email : dborca@users.sourceforge.net
@@ -61,6 +61,9 @@ CFLAGS = -Wall -W -pedantic
 CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
 CFLAGS += -I$(TOP)/include -I../util
 CFLAGS += -DGLUT_IMPORT_LIB
+ifeq ($(FX),1)
+CFLAGS += -DFX
+endif
 
 LD = gxx
 LDFLAGS = -s -L$(TOP)/lib
index bf2ac05b8b4f5a5862f7740162b7ac0b52df6f26..94ffbe639ad91368bcd84dec2efd90228b01eb4e 100644 (file)
@@ -20,7 +20,7 @@
 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-# MinGW samples makefile v1.0 for Mesa
+# MinGW samples makefile v1.1 for Mesa
 #
 #  Copyright (C) 2002 - Borca Daniel
 #  Email : dborca@users.sourceforge.net
@@ -50,6 +50,9 @@ CC = mingw32-gcc
 CFLAGS = -Wall -W -pedantic
 CFLAGS += -O2 -ffast-math -mcpu=$(CPU)
 CFLAGS += -I$(TOP)/include -I../util
+ifeq ($(FX),1)
+CFLAGS += -DFX
+endif
 CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK -D_STDCALL_SUPPORTED
 CFLAGS += -D_WINDEF_ -D_WINGDI_
 
index 9738d6ea60625d4720af398e51c70a2c6f756248..c00bd83f786fc284870d589bde8c90416ba6173b 100644 (file)
@@ -868,8 +868,8 @@ fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx)
    struct tdfx_texcombine tex0, tex1;
    GrCombineLocal_t localc, locala;
    tfxTexInfo *ti0, *ti1;
-   struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
-   struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
+   struct gl_texture_object *tObj0 = ctx->Texture.Unit[1].Current2D;
+   struct gl_texture_object *tObj1 = ctx->Texture.Unit[0].Current2D;
    GLuint envmode, ifmt, unitsmode;
    int tmu0 = 0, tmu1 = 1;
 
@@ -973,7 +973,7 @@ fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx)
         break;
       }
    case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND):   /* Only for GLQuake */
-      if (tmu1 == FX_TMU1) {
+      if (tmu0 == FX_TMU1) {
          tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;
          tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;
          tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
@@ -1087,6 +1087,48 @@ fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx)
          alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;
         break;
       }
+
+   case (FX_UM_E0_REPLACE | FX_UM_E1_ADD):     /* Vulpine Sky */
+      {
+        GLboolean isalpha[FX_NUM_TMU];
+
+        isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA);
+        isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA);
+
+        if (isalpha[FX_TMU1]) {
+            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_ZERO;
+            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;
+            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;
+            tex1.InvertRGB     = FXTRUE;
+        } else {
+            tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;
+            tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;
+            tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+            tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;
+         }
+
+        if (isalpha[FX_TMU0]) {
+            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_SCALE_OTHER;
+            tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;
+            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+            tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;
+        } else {
+            tex0.FunctionRGB   = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+            tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;
+            tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+            tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;
+         }
+
+         colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+         colorComb.Factor   = GR_COMBINE_FACTOR_ONE;
+         colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;
+
+         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+         alphaComb.Factor   = GR_COMBINE_FACTOR_ONE;
+         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;
+        break;
+      }
    default:
       fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock: Unexpected dual texture mode encountered\n");
       return;
index f4435bf0de5785688c0d295e3377d8ec669ca4ae..d1c8d9dc05d1502852afe543d43c7426f033e867 100644 (file)
@@ -379,6 +379,29 @@ fxSetupTextureEnvNapalm_NoLock(GLcontext * ctx, GLuint textureset, GLuint tmu, G
       break;
     /* COMBINE_EXT */
     case GL_COMBINE_EXT:
+#if 0/*666*/
+{
+ fprintf(stderr, "Texture Unit %d\n", textureset);
+ fprintf(stderr, "  GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode));
+ fprintf(stderr, "  GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineModeRGB));
+ fprintf(stderr, "  GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineModeA));
+ fprintf(stderr, "  GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceRGB[0]));
+ fprintf(stderr, "  GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceRGB[1]));
+ fprintf(stderr, "  GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceRGB[2]));
+ fprintf(stderr, "  GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceA[0]));
+ fprintf(stderr, "  GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceA[1]));
+ fprintf(stderr, "  GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceA[2]));
+ fprintf(stderr, "  GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandRGB[0]));
+ fprintf(stderr, "  GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandRGB[1]));
+ fprintf(stderr, "  GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandRGB[2]));
+ fprintf(stderr, "  GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandA[0]));
+ fprintf(stderr, "  GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandA[1]));
+ fprintf(stderr, "  GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandA[2]));
+ fprintf(stderr, "  GL_RGB_SCALE = %d\n", 1 << texUnit->CombineScaleShiftRGB);
+ fprintf(stderr, "  GL_ALPHA_SCALE = %d\n", 1 << texUnit->CombineScaleShiftA);
+ fprintf(stderr, "  GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", envColor[0], envColor[1], envColor[2], envColor[3]);
+}
+#endif
       /* [dBorca] Hack alert:
        * INCOMPLETE!!!
        */
@@ -410,6 +433,70 @@ fxSetupTextureEnvNapalm_NoLock(GLcontext * ctx, GLuint textureset, GLuint tmu, G
                                        texUnit->CombineOperandRGB[1]);
                   colorComb.SourceD = GR_CMBX_ZERO;
                   break;
+             case GL_REPLACE:
+                  /* Arg0 == (A + 0) * 1 + 0 */
+                  TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
+                                       texUnit->CombineSourceRGB[0],
+                                       texUnit->CombineOperandRGB[0],
+                                       localc, locala);
+                  TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
+                                        texUnit->CombineOperandRGB[0]);
+                  colorComb.SourceB = GR_CMBX_ZERO;
+                  colorComb.ModeB   = GR_FUNC_MODE_ZERO;
+                  colorComb.SourceC = GR_CMBX_ZERO;
+                  colorComb.InvertC = FXTRUE;
+                  colorComb.SourceD = GR_CMBX_ZERO;
+                  break;
+             case GL_ADD:
+                  /* Arg0 + Arg1 = (A + B) * 1 + 0 */
+                  TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
+                                       texUnit->CombineSourceRGB[0],
+                                       texUnit->CombineOperandRGB[0],
+                                       localc, locala);
+                  TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
+                                        texUnit->CombineOperandRGB[0]);
+                  TEXENV_SETUP_ARG_RGB(colorComb.SourceB,
+                                       texUnit->CombineSourceRGB[1],
+                                       texUnit->CombineOperandRGB[1],
+                                       localc, locala);
+                  TEXENV_SETUP_MODE_RGB(colorComb.ModeB,
+                                        texUnit->CombineOperandRGB[1]);
+                  colorComb.SourceC = GR_CMBX_ZERO;
+                  colorComb.InvertC = FXTRUE;
+                  colorComb.SourceD = GR_CMBX_ZERO;
+                  break;
+             case GL_INTERPOLATE_EXT:
+                  /* Arg0 * Arg2 + Arg1 * (1 - Arg2) ==
+                   * (Arg0 - Arg1) * Arg2 + Arg1 == (A - B) * C + D
+                   */
+                  TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
+                                       texUnit->CombineSourceRGB[0],
+                                       texUnit->CombineOperandRGB[0],
+                                       localc, locala);
+                  TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
+                                        texUnit->CombineOperandRGB[0]);
+                  TEXENV_SETUP_ARG_RGB(colorComb.SourceB,
+                                       texUnit->CombineSourceRGB[1],
+                                       texUnit->CombineOperandRGB[1],
+                                       localc, locala);
+                  if (TEXENV_OPERAND_INVERTED(texUnit->CombineOperandRGB[1])) {
+                     /* Hack alert!!! This case is wrong!!! */
+                     fprintf(stderr, "COMBINE_EXT_color: WRONG!!!\n");
+                     colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+                  } else {
+                     colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+                  }
+                  /*
+                   * The Source/Operand for the C value must
+                   * specify some kind of alpha value.
+                   */
+                  TEXENV_SETUP_ARG_A(colorComb.SourceC,
+                                     texUnit->CombineSourceRGB[2],
+                                     texUnit->CombineOperandRGB[2],
+                                     locala);
+                  colorComb.InvertC = FXFALSE;
+                  colorComb.SourceD = GR_CMBX_B;
+                  break;
              default:
                   fprintf(stderr, "COMBINE_EXT_color: %s\n",
                                   _mesa_lookup_enum_by_nr(texUnit->CombineModeRGB));
@@ -434,6 +521,38 @@ fxSetupTextureEnvNapalm_NoLock(GLcontext * ctx, GLuint textureset, GLuint tmu, G
                                        texUnit->CombineOperandA[1]);
                   alphaComb.SourceD = GR_CMBX_ZERO;
                   break;
+             case GL_REPLACE:
+                 /* Arg0 == (A + 0) * 1 + 0 */
+                  TEXENV_SETUP_ARG_A(alphaComb.SourceA,
+                                     texUnit->CombineSourceA[0],
+                                     texUnit->CombineOperandA[0],
+                                     locala);
+                  TEXENV_SETUP_MODE_A(alphaComb.ModeA,
+                                      texUnit->CombineOperandA[0]);
+                  alphaComb.SourceB = GR_CMBX_ZERO;
+                  alphaComb.ModeB   = GR_FUNC_MODE_ZERO;
+                  alphaComb.SourceC = GR_CMBX_ZERO;
+                  alphaComb.InvertC = FXTRUE;
+                  alphaComb.SourceD = GR_CMBX_ZERO;
+                  break;
+             case GL_ADD:
+                  /* Arg0 + Arg1 = (A + B) * 1 + 0 */
+                  TEXENV_SETUP_ARG_A(alphaComb.SourceA,
+                                     texUnit->CombineSourceA[0],
+                                     texUnit->CombineOperandA[0],
+                                     locala);
+                  TEXENV_SETUP_MODE_A(alphaComb.ModeA,
+                                      texUnit->CombineOperandA[0]);
+                  TEXENV_SETUP_ARG_A(alphaComb.SourceB,
+                                     texUnit->CombineSourceA[1],
+                                     texUnit->CombineOperandA[1],
+                                     locala);
+                  TEXENV_SETUP_MODE_A(alphaComb.ModeB,
+                                      texUnit->CombineOperandA[1]);
+                  alphaComb.SourceC = GR_CMBX_ZERO;
+                  alphaComb.InvertC = FXTRUE;
+                  alphaComb.SourceD = GR_CMBX_ZERO;
+                  break;
              default:
                   fprintf(stderr, "COMBINE_EXT_alpha: %s\n",
                                   _mesa_lookup_enum_by_nr(texUnit->CombineModeA));
@@ -1037,8 +1156,8 @@ fxSetupTextureDoubleTMUNapalm_NoLock(GLcontext * ctx)
 {
    fxMesaContext fxMesa = FX_CONTEXT(ctx);
    tfxTexInfo *ti0, *ti1;
-   struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
-   struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
+   struct gl_texture_object *tObj0 = ctx->Texture.Unit[1].Current2D;
+   struct gl_texture_object *tObj1 = ctx->Texture.Unit[0].Current2D;
    GLuint unitsmode;
    int tmu0 = 0, tmu1 = 1;
 
index 7e3445f8075e3a4562cee0cbc08415dc0894534d..7a275ad1c9f057e2c28af3bd040bb0514b896ce4 100644 (file)
@@ -517,13 +517,11 @@ void fxChooseVertexState( GLcontext *ctx )
 
    if (ctx->Texture._EnabledUnits & 0x2) {
       if (ctx->Texture._EnabledUnits & 0x1) {
-        ind |= SETUP_TMU1|SETUP_TMU0;
-      }
-      else {
-        fxMesa->tmu_source[0] = 1;
-        fxMesa->tmu_source[1] = 0;
-        ind |= SETUP_TMU0;
+        ind |= SETUP_TMU1;
       }
+      ind |= SETUP_TMU0;
+      fxMesa->tmu_source[0] = 1;
+      fxMesa->tmu_source[1] = 0;
    }
    else if (ctx->Texture._EnabledUnits & 0x1) {
       ind |= SETUP_TMU0;