diff options
author | Daniel Borca <dborca@users.sourceforge.net> | 2003-12-23 14:11:22 +0000 |
---|---|---|
committer | Daniel Borca <dborca@users.sourceforge.net> | 2003-12-23 14:11:22 +0000 |
commit | 0ee5f6203c125898fdffbec8d5eea9269aa1559e (patch) | |
tree | 7120d157cec96a80d4515a79f3c2c83675a23806 | |
parent | fabb9734ddd1a9b43e7835190f2f4828add2db3c (diff) |
reverted TMUs for proper multitexturing
-rw-r--r-- | progs/samples/Makefile.DJ | 5 | ||||
-rw-r--r-- | progs/samples/Makefile.mgw | 5 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxsetup.c | 48 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxsetup.h | 123 | ||||
-rw-r--r-- | src/mesa/drivers/glide/fxvb.c | 10 |
5 files changed, 178 insertions, 13 deletions
diff --git a/progs/samples/Makefile.DJ b/progs/samples/Makefile.DJ index 2f0f687587..9b1055ce73 100644 --- a/progs/samples/Makefile.DJ +++ b/progs/samples/Makefile.DJ @@ -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 diff --git a/progs/samples/Makefile.mgw b/progs/samples/Makefile.mgw index bf2ac05b8b..94ffbe639a 100644 --- a/progs/samples/Makefile.mgw +++ b/progs/samples/Makefile.mgw @@ -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_ diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c index 9738d6ea60..c00bd83f78 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -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; diff --git a/src/mesa/drivers/glide/fxsetup.h b/src/mesa/drivers/glide/fxsetup.h index f4435bf0de..d1c8d9dc05 100644 --- a/src/mesa/drivers/glide/fxsetup.h +++ b/src/mesa/drivers/glide/fxsetup.h @@ -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; diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c index 7e3445f807..7a275ad1c9 100644 --- a/src/mesa/drivers/glide/fxvb.c +++ b/src/mesa/drivers/glide/fxvb.c @@ -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; |