diff options
author | Brian Paul <[email protected]> | 2001-03-03 20:59:06 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2001-03-03 20:59:06 +0000 |
commit | d62269757b3e40e4ddae54cc8bf0cc0e1d5d1eae (patch) | |
tree | df3dd3d5837fd93e05972d8abba2d75f27032012 /src/mesa/drivers/glide/fxsetup.c | |
parent | 188f2949eaf181f4aab041a6dad26fa76e746eee (diff) |
used indent to clean-up the code
Diffstat (limited to 'src/mesa/drivers/glide/fxsetup.c')
-rw-r--r-- | src/mesa/drivers/glide/fxsetup.c | 2889 |
1 files changed, 1451 insertions, 1438 deletions
diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c index 5d844473d81..dc2db8e3198 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -56,562 +56,561 @@ #include "tnl/t_context.h" -static GLuint fxGetTexSetConfiguration(GLcontext *ctx, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1); -static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset); -static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1); -static void fxSetupTexture_NoLock(GLcontext *ctx); -static void fxSetupTexture(GLcontext *ctx); -static void fxSetupBlend(GLcontext *ctx); -static void fxSetupDepthTest(GLcontext *ctx); -static void fxSetupScissor(GLcontext *ctx); -static void fxSetupCull(GLcontext *ctx); -static void fx_print_state_flags( const char *msg, GLuint flags); +static GLuint fxGetTexSetConfiguration(GLcontext * ctx, + struct gl_texture_object *tObj0, + struct gl_texture_object *tObj1); +static void fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, + GLuint textureset); +static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, + struct gl_texture_object *tObj0, + struct gl_texture_object *tObj1); +static void fxSetupTexture_NoLock(GLcontext * ctx); +static void fxSetupTexture(GLcontext * ctx); +static void fxSetupBlend(GLcontext * ctx); +static void fxSetupDepthTest(GLcontext * ctx); +static void fxSetupScissor(GLcontext * ctx); +static void fxSetupCull(GLcontext * ctx); +static void fx_print_state_flags(const char *msg, GLuint flags); /*static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint);*/ -static GLboolean fxMultipassTexture( GLcontext *, GLuint ); +static GLboolean fxMultipassTexture(GLcontext *, GLuint); -static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj) +static void +fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj) { - tfxTexInfo *ti=fxTMGetTexInfo(tObj); - GLint minl, maxl; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxTexValidate(...) Start\n"); - } - - if(ti->validated) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n"); - } - return; - } - - ti->tObj=tObj; - minl=ti->minLevel=tObj->BaseLevel; - maxl=ti->maxLevel=MIN2(tObj->MaxLevel,tObj->Image[0]->MaxLog2); - - fxTexGetInfo(tObj->Image[minl]->Width, tObj->Image[minl]->Height, - &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)), - &(ti->sScale), &(ti->tScale), - &(ti->int_sScale), &(ti->int_tScale), - NULL, NULL); - - if((tObj->MinFilter!=GL_NEAREST) && (tObj->MinFilter!=GL_LINEAR)) - fxTexGetInfo(tObj->Image[maxl]->Width,tObj->Image[maxl]->Height, - &(FX_smallLodLog2(ti->info)),NULL, - NULL,NULL, - NULL,NULL, - NULL,NULL); - else - FX_smallLodLog2(ti->info)=FX_largeLodLog2(ti->info); - - fxTexGetFormat(tObj->Image[minl]->IntFormat,&(ti->info.format),&(ti->baseLevelInternalFormat)); - - switch (tObj->WrapS) { - case GL_CLAMP_TO_EDGE: - /* What's this really mean compared to GL_CLAMP? */ - case GL_CLAMP: - ti->sClamp=1; - break; - case GL_REPEAT: - ti->sClamp=0; - break; - default: - ; /* silence compiler warning */ - } - switch (tObj->WrapT) { - case GL_CLAMP_TO_EDGE: - /* What's this really mean compared to GL_CLAMP? */ - case GL_CLAMP: - ti->tClamp=1; - break; - case GL_REPEAT: - ti->tClamp=0; - break; - default: - ; /* silence compiler warning */ - } - - ti->validated=GL_TRUE; - - ti->info.data=NULL; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxTexValidate(...) End\n"); - } + tfxTexInfo *ti = fxTMGetTexInfo(tObj); + GLint minl, maxl; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxTexValidate(...) Start\n"); + } + + if (ti->validated) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, + "fxmesa: fxTexValidate(...) End (validated=GL_TRUE)\n"); + } + return; + } + + ti->tObj = tObj; + minl = ti->minLevel = tObj->BaseLevel; + maxl = ti->maxLevel = MIN2(tObj->MaxLevel, tObj->Image[0]->MaxLog2); + + fxTexGetInfo(tObj->Image[minl]->Width, tObj->Image[minl]->Height, + &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)), + &(ti->sScale), &(ti->tScale), + &(ti->int_sScale), &(ti->int_tScale), NULL, NULL); + + if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) + fxTexGetInfo(tObj->Image[maxl]->Width, tObj->Image[maxl]->Height, + &(FX_smallLodLog2(ti->info)), NULL, + NULL, NULL, NULL, NULL, NULL, NULL); + else + FX_smallLodLog2(ti->info) = FX_largeLodLog2(ti->info); + + fxTexGetFormat(tObj->Image[minl]->IntFormat, &(ti->info.format), + &(ti->baseLevelInternalFormat)); + + switch (tObj->WrapS) { + case GL_CLAMP_TO_EDGE: + /* What's this really mean compared to GL_CLAMP? */ + case GL_CLAMP: + ti->sClamp = 1; + break; + case GL_REPEAT: + ti->sClamp = 0; + break; + default: + ; /* silence compiler warning */ + } + switch (tObj->WrapT) { + case GL_CLAMP_TO_EDGE: + /* What's this really mean compared to GL_CLAMP? */ + case GL_CLAMP: + ti->tClamp = 1; + break; + case GL_REPEAT: + ti->tClamp = 0; + break; + default: + ; /* silence compiler warning */ + } + + ti->validated = GL_TRUE; + + ti->info.data = NULL; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxTexValidate(...) End\n"); + } } -static void fxPrintUnitsMode( const char *msg, GLuint mode ) +static void +fxPrintUnitsMode(const char *msg, GLuint mode) { - fprintf(stderr, + fprintf(stderr, "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", msg, mode, - (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "", - (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "", - (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "", - (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "", - (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "", - (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "", - (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "", - (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "", - (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "", - (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "", + (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "", + (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "", + (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "", + (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "", + (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "", + (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "", + (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "", + (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "", + (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "", + (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "", (mode & FX_UM_E0_LUMINANCE_ALPHA) ? "E0_LUMINANCE_ALPHA, " : "", - (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "", - (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "", - (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "", - (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "", - (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "", + (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "", + (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "", + (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "", + (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "", + (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "", (mode & FX_UM_E1_LUMINANCE_ALPHA) ? "E1_LUMINANCE_ALPHA, " : "", - (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "", - (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "", - (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "", - (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "", - (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "", - (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "", - (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : ""); + (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "", + (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "", + (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "", + (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "", + (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "", + (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "", + (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : ""); } -static GLuint fxGetTexSetConfiguration(GLcontext *ctx, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1) +static GLuint +fxGetTexSetConfiguration(GLcontext * ctx, + struct gl_texture_object *tObj0, + struct gl_texture_object *tObj1) { - GLuint unitsmode=0; - GLuint envmode=0; - GLuint ifmt=0; + GLuint unitsmode = 0; + GLuint envmode = 0; + GLuint ifmt = 0; + + if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 || + (ctx->Point.SmoothFlag) || + (ctx->Line.SmoothFlag) || + (ctx->Polygon.SmoothFlag)) unitsmode |= FX_UM_ALPHA_ITERATED; + else + unitsmode |= FX_UM_ALPHA_CONSTANT; + + if (ctx->Light.ShadeModel == GL_SMOOTH || 1) + unitsmode |= FX_UM_COLOR_ITERATED; + else + unitsmode |= FX_UM_COLOR_CONSTANT; + + + + /* + OpenGL Feeds Texture 0 into Texture 1 + Glide Feeds Texture 1 into Texture 0 + */ + if (tObj0) { + tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0); + + switch (ti0->baseLevelInternalFormat) { + case GL_ALPHA: + ifmt |= FX_UM_E0_ALPHA; + break; + case GL_LUMINANCE: + ifmt |= FX_UM_E0_LUMINANCE; + break; + case GL_LUMINANCE_ALPHA: + ifmt |= FX_UM_E0_LUMINANCE_ALPHA; + break; + case GL_INTENSITY: + ifmt |= FX_UM_E0_INTENSITY; + break; + case GL_RGB: + ifmt |= FX_UM_E0_RGB; + break; + case GL_RGBA: + ifmt |= FX_UM_E0_RGBA; + break; + } - if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 || - (ctx->Point.SmoothFlag) || - (ctx->Line.SmoothFlag) || - (ctx->Polygon.SmoothFlag)) - unitsmode|=FX_UM_ALPHA_ITERATED; - else - unitsmode|=FX_UM_ALPHA_CONSTANT; + switch (ctx->Texture.Unit[0].EnvMode) { + case GL_DECAL: + envmode |= FX_UM_E0_DECAL; + break; + case GL_MODULATE: + envmode |= FX_UM_E0_MODULATE; + break; + case GL_REPLACE: + envmode |= FX_UM_E0_REPLACE; + break; + case GL_BLEND: + envmode |= FX_UM_E0_BLEND; + break; + case GL_ADD: + envmode |= FX_UM_E0_ADD; + break; + default: + /* do nothing */ + break; + } + } - if(ctx->Light.ShadeModel==GL_SMOOTH || 1) - unitsmode|=FX_UM_COLOR_ITERATED; - else - unitsmode|=FX_UM_COLOR_CONSTANT; + if (tObj1) { + tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1); + + switch (ti1->baseLevelInternalFormat) { + case GL_ALPHA: + ifmt |= FX_UM_E1_ALPHA; + break; + case GL_LUMINANCE: + ifmt |= FX_UM_E1_LUMINANCE; + break; + case GL_LUMINANCE_ALPHA: + ifmt |= FX_UM_E1_LUMINANCE_ALPHA; + break; + case GL_INTENSITY: + ifmt |= FX_UM_E1_INTENSITY; + break; + case GL_RGB: + ifmt |= FX_UM_E1_RGB; + break; + case GL_RGBA: + ifmt |= FX_UM_E1_RGBA; + break; + default: + /* do nothing */ + break; + } + switch (ctx->Texture.Unit[1].EnvMode) { + case GL_DECAL: + envmode |= FX_UM_E1_DECAL; + break; + case GL_MODULATE: + envmode |= FX_UM_E1_MODULATE; + break; + case GL_REPLACE: + envmode |= FX_UM_E1_REPLACE; + break; + case GL_BLEND: + envmode |= FX_UM_E1_BLEND; + break; + case GL_ADD: + envmode |= FX_UM_E1_ADD; + break; + default: + /* do nothing */ + break; + } + } + unitsmode |= (ifmt | envmode); - /* - OpenGL Feeds Texture 0 into Texture 1 - Glide Feeds Texture 1 into Texture 0 - */ - if(tObj0) { - tfxTexInfo *ti0=fxTMGetTexInfo(tObj0); + if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) + fxPrintUnitsMode("unitsmode", unitsmode); - switch(ti0->baseLevelInternalFormat) { - case GL_ALPHA: - ifmt|=FX_UM_E0_ALPHA; - break; - case GL_LUMINANCE: - ifmt|=FX_UM_E0_LUMINANCE; - break; - case GL_LUMINANCE_ALPHA: - ifmt|=FX_UM_E0_LUMINANCE_ALPHA; - break; - case GL_INTENSITY: - ifmt|=FX_UM_E0_INTENSITY; - break; - case GL_RGB: - ifmt|=FX_UM_E0_RGB; - break; - case GL_RGBA: - ifmt|=FX_UM_E0_RGBA; - break; - } + return unitsmode; +} - switch(ctx->Texture.Unit[0].EnvMode) { - case GL_DECAL: - envmode|=FX_UM_E0_DECAL; - break; - case GL_MODULATE: - envmode|=FX_UM_E0_MODULATE; - break; - case GL_REPLACE: - envmode|=FX_UM_E0_REPLACE; - break; - case GL_BLEND: - envmode|=FX_UM_E0_BLEND; - break; - case GL_ADD: - envmode|=FX_UM_E0_ADD; - break; - default: - /* do nothing */ - break; - } - } +/************************************************************************/ +/************************* Rendering Mode SetUp *************************/ +/************************************************************************/ - if(tObj1) { - tfxTexInfo *ti1=fxTMGetTexInfo(tObj1); +/************************* Single Texture Set ***************************/ - switch(ti1->baseLevelInternalFormat) { - case GL_ALPHA: - ifmt|=FX_UM_E1_ALPHA; - break; - case GL_LUMINANCE: - ifmt|=FX_UM_E1_LUMINANCE; - break; - case GL_LUMINANCE_ALPHA: - ifmt|=FX_UM_E1_LUMINANCE_ALPHA; - break; - case GL_INTENSITY: - ifmt|=FX_UM_E1_INTENSITY; - break; - case GL_RGB: - ifmt|=FX_UM_E1_RGB; - break; - case GL_RGBA: - ifmt|=FX_UM_E1_RGBA; - break; - default: - /* do nothing */ - break; - } +static void +fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj) +{ + tfxTexInfo *ti = fxTMGetTexInfo(tObj); + int tmu; + + /* Make sure we're not loaded incorrectly */ + if (ti->isInTM) { + if (ti->LODblend) { + if (ti->whichTMU != FX_TMU_SPLIT) + fxTMMoveOutTM(fxMesa, tObj); + } + else { + if (ti->whichTMU == FX_TMU_SPLIT) + fxTMMoveOutTM(fxMesa, tObj); + } + } - switch(ctx->Texture.Unit[1].EnvMode) { - case GL_DECAL: - envmode|=FX_UM_E1_DECAL; - break; - case GL_MODULATE: - envmode|=FX_UM_E1_MODULATE; - break; - case GL_REPLACE: - envmode|=FX_UM_E1_REPLACE; - break; - case GL_BLEND: - envmode|=FX_UM_E1_BLEND; - break; - case GL_ADD: - envmode|=FX_UM_E1_ADD; - break; - default: - /* do nothing */ - break; - } - } + /* Make sure we're loaded correctly */ + if (!ti->isInTM) { + if (ti->LODblend) + fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU_SPLIT); + else { + if (fxMesa->haveTwoTMUs) { + if (fxMesa->freeTexMem[FX_TMU0] > + FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH, + &(ti->info))) { + fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0); + } + else { + fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU1); + } + } + else + fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0); + } + } - unitsmode|=(ifmt | envmode); + if (ti->LODblend && ti->whichTMU == FX_TMU_SPLIT) { + if ((ti->info.format == GR_TEXFMT_P_8) + && (!fxMesa->haveGlobalPaletteTexture)) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: uploading texture palette\n"); + } + FX_grTexDownloadTable_NoLock(GR_TMU0, GR_TEXTABLE_PALETTE, + &(ti->palette)); + FX_grTexDownloadTable_NoLock(GR_TMU1, GR_TEXTABLE_PALETTE, + &(ti->palette)); + } - if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) - fxPrintUnitsMode("unitsmode", unitsmode); + FX_grTexClampMode_NoLock(GR_TMU0, ti->sClamp, ti->tClamp); + FX_grTexClampMode_NoLock(GR_TMU1, ti->sClamp, ti->tClamp); + FX_grTexFilterMode_NoLock(GR_TMU0, ti->minFilt, ti->maxFilt); + FX_grTexFilterMode_NoLock(GR_TMU1, ti->minFilt, ti->maxFilt); + FX_grTexMipMapMode_NoLock(GR_TMU0, ti->mmMode, ti->LODblend); + FX_grTexMipMapMode_NoLock(GR_TMU1, ti->mmMode, ti->LODblend); + + FX_grTexSource_NoLock(GR_TMU0, ti->tm[FX_TMU0]->startAddr, + GR_MIPMAPLEVELMASK_ODD, &(ti->info)); + FX_grTexSource_NoLock(GR_TMU1, ti->tm[FX_TMU1]->startAddr, + GR_MIPMAPLEVELMASK_EVEN, &(ti->info)); + } + else { + if (ti->whichTMU == FX_TMU_BOTH) + tmu = FX_TMU0; + else + tmu = ti->whichTMU; - return unitsmode; -} + if ((ti->info.format == GR_TEXFMT_P_8) + && (!fxMesa->haveGlobalPaletteTexture)) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: uploading texture palette\n"); + } + FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE, + &(ti->palette)); + } -/************************************************************************/ -/************************* Rendering Mode SetUp *************************/ -/************************************************************************/ + /* KW: The alternative is to do the download to the other tmu. If + * we get to this point, I think it means we are thrashing the + * texture memory, so perhaps it's not a good idea. + */ + if (ti->LODblend && (MESA_VERBOSE & VERBOSE_DRIVER)) + fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n"); -/************************* Single Texture Set ***************************/ + FX_grTexClampMode_NoLock(tmu, ti->sClamp, ti->tClamp); + FX_grTexFilterMode_NoLock(tmu, ti->minFilt, ti->maxFilt); + FX_grTexMipMapMode_NoLock(tmu, ti->mmMode, FXFALSE); -static void fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj) -{ - tfxTexInfo *ti=fxTMGetTexInfo(tObj); - int tmu; - - /* Make sure we're not loaded incorrectly */ - if (ti->isInTM) { - if (ti->LODblend) { - if (ti->whichTMU!=FX_TMU_SPLIT) - fxTMMoveOutTM(fxMesa, tObj); - } else { - if (ti->whichTMU==FX_TMU_SPLIT) - fxTMMoveOutTM(fxMesa, tObj); - } - } - - /* Make sure we're loaded correctly */ - if (!ti->isInTM) { - if (ti->LODblend) - fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU_SPLIT); - else { - if (fxMesa->haveTwoTMUs) { - if (fxMesa->freeTexMem[FX_TMU0] > - FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH, - &(ti->info))) { - fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU0); - } else { - fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU1); - } - } else - fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0); - } - } - - if (ti->LODblend && ti->whichTMU == FX_TMU_SPLIT) { - if ((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: uploading texture palette\n"); - } - FX_grTexDownloadTable_NoLock(GR_TMU0,GR_TEXTABLE_PALETTE,&(ti->palette)); - FX_grTexDownloadTable_NoLock(GR_TMU1,GR_TEXTABLE_PALETTE,&(ti->palette)); - } - - FX_grTexClampMode_NoLock(GR_TMU0,ti->sClamp,ti->tClamp); - FX_grTexClampMode_NoLock(GR_TMU1,ti->sClamp,ti->tClamp); - FX_grTexFilterMode_NoLock(GR_TMU0,ti->minFilt,ti->maxFilt); - FX_grTexFilterMode_NoLock(GR_TMU1,ti->minFilt,ti->maxFilt); - FX_grTexMipMapMode_NoLock(GR_TMU0,ti->mmMode,ti->LODblend); - FX_grTexMipMapMode_NoLock(GR_TMU1,ti->mmMode,ti->LODblend); - - FX_grTexSource_NoLock(GR_TMU0,ti->tm[FX_TMU0]->startAddr, - GR_MIPMAPLEVELMASK_ODD,&(ti->info)); - FX_grTexSource_NoLock(GR_TMU1,ti->tm[FX_TMU1]->startAddr, - GR_MIPMAPLEVELMASK_EVEN,&(ti->info)); - } else { - if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0; - else tmu=ti->whichTMU; - - if((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: uploading texture palette\n"); - } - FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE, &(ti->palette)); - } - - /* KW: The alternative is to do the download to the other tmu. If - * we get to this point, I think it means we are thrashing the - * texture memory, so perhaps it's not a good idea. - */ - if (ti->LODblend && (MESA_VERBOSE&VERBOSE_DRIVER)) - fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n"); - - FX_grTexClampMode_NoLock(tmu, ti->sClamp, ti->tClamp); - FX_grTexFilterMode_NoLock(tmu, ti->minFilt, ti->maxFilt); - FX_grTexMipMapMode_NoLock(tmu, ti->mmMode, FXFALSE); - - FX_grTexSource_NoLock(tmu, ti->tm[tmu]->startAddr, - GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); - } + FX_grTexSource_NoLock(tmu, ti->tm[tmu]->startAddr, + GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); + } } -static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, - FxBool LODblend) +static void +fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSelectSingleTMUSrc(%d,%d)\n",tmu,LODblend); - } - - if (LODblend) { - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, - GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, - FXFALSE,FXFALSE); - - if (fxMesa->haveTwoTMUs) - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - fxMesa->tmuSrc=FX_TMU_SPLIT; - } - else { - if (tmu!=FX_TMU1) { - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - if (fxMesa->haveTwoTMUs) { - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - } - fxMesa->tmuSrc=FX_TMU0; - } - else { - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - - /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */ + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSelectSingleTMUSrc(%d,%d)\n", tmu, LODblend); + } + if (LODblend) { FX_grTexCombine_NoLock(GR_TMU0, GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_ONE, + GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_ONE, - FXFALSE,FXFALSE); - - fxMesa->tmuSrc=FX_TMU1; - } - } + GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION, + FXFALSE, FXFALSE); + + if (fxMesa->haveTwoTMUs) + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + fxMesa->tmuSrc = FX_TMU_SPLIT; + } + else { + if (tmu != FX_TMU1) { + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + if (fxMesa->haveTwoTMUs) { + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + } + fxMesa->tmuSrc = FX_TMU0; + } + else { + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + + /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */ + + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_BLEND, + GR_COMBINE_FACTOR_ONE, + GR_COMBINE_FUNCTION_BLEND, + GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE); + + fxMesa->tmuSrc = FX_TMU1; + } + } } -static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) +static void +fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GrCombineLocal_t localc,locala; - GLuint unitsmode; - GLint ifmt; - tfxTexInfo *ti; - struct gl_texture_object *tObj=ctx->Texture.Unit[textureset].Current2D; - int tmu; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupTextureSingleTMU(...) Start\n"); - } + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + GrCombineLocal_t localc, locala; + GLuint unitsmode; + GLint ifmt; + tfxTexInfo *ti; + struct gl_texture_object *tObj = ctx->Texture.Unit[textureset].Current2D; + int tmu; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupTextureSingleTMU(...) Start\n"); + } - ti=fxTMGetTexInfo(tObj); + ti = fxTMGetTexInfo(tObj); - fxTexValidate(ctx,tObj); + fxTexValidate(ctx, tObj); - fxSetupSingleTMU_NoLock(fxMesa,tObj); + fxSetupSingleTMU_NoLock(fxMesa, tObj); - if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0; - else tmu=ti->whichTMU; - if (fxMesa->tmuSrc!=tmu) - fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend); + if (ti->whichTMU == FX_TMU_BOTH) + tmu = FX_TMU0; + else + tmu = ti->whichTMU; + if (fxMesa->tmuSrc != tmu) + fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend); - if(textureset==0 || !fxMesa->haveTwoTMUs) - unitsmode=fxGetTexSetConfiguration(ctx,tObj,NULL); - else - unitsmode=fxGetTexSetConfiguration(ctx,NULL,tObj); + if (textureset == 0 || !fxMesa->haveTwoTMUs) + unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL); + else + unitsmode = fxGetTexSetConfiguration(ctx, NULL, tObj); /* if(fxMesa->lastUnitsMode==unitsmode) */ /* return; */ - fxMesa->lastUnitsMode=unitsmode; - - fxMesa->stw_hint_state = 0; - FX_grHints_NoLock(GR_HINT_STWHINT,0); - - ifmt=ti->baseLevelInternalFormat; - - if(unitsmode & FX_UM_ALPHA_ITERATED) - locala=GR_COMBINE_LOCAL_ITERATED; - else - locala=GR_COMBINE_LOCAL_CONSTANT; - - if(unitsmode & FX_UM_COLOR_ITERATED) - localc=GR_COMBINE_LOCAL_ITERATED; - else - localc=GR_COMBINE_LOCAL_CONSTANT; - - if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) - fprintf(stderr, "fxMesa: fxSetupTextureSingleTMU, envmode is %s\n", - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode)); - - switch(ctx->Texture.Unit[textureset].EnvMode) { - case GL_DECAL: - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_BLEND, - GR_COMBINE_FACTOR_TEXTURE_ALPHA, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - case GL_MODULATE: - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - locala, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - if(ifmt==GL_ALPHA) - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + fxMesa->lastUnitsMode = unitsmode; + + fxMesa->stw_hint_state = 0; + FX_grHints_NoLock(GR_HINT_STWHINT, 0); + + ifmt = ti->baseLevelInternalFormat; + + if (unitsmode & FX_UM_ALPHA_ITERATED) + locala = GR_COMBINE_LOCAL_ITERATED; + else + locala = GR_COMBINE_LOCAL_CONSTANT; + + if (unitsmode & FX_UM_COLOR_ITERATED) + localc = GR_COMBINE_LOCAL_ITERATED; + else + localc = GR_COMBINE_LOCAL_CONSTANT; + + if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) + fprintf(stderr, "fxMesa: fxSetupTextureSingleTMU, envmode is %s\n", + _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode)); + + switch (ctx->Texture.Unit[textureset].EnvMode) { + case GL_DECAL: + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); - else - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + locala, GR_COMBINE_OTHER_NONE, FXFALSE); + + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_BLEND, + GR_COMBINE_FACTOR_TEXTURE_ALPHA, + localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + break; + case GL_MODULATE: + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - case GL_BLEND: + locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + + if (ifmt == GL_ALPHA) + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + localc, GR_COMBINE_OTHER_NONE, FXFALSE); + else + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_LOCAL, + localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + break; + case GL_BLEND: #if 0 - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - locala, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - if (ifmt==GL_ALPHA) - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); - else - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXTRUE); - ctx->Driver.MultipassFunc = fxMultipassBlend; + locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + if (ifmt == GL_ALPHA) + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + localc, GR_COMBINE_OTHER_NONE, FXFALSE); + else + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, + GR_COMBINE_FACTOR_LOCAL, + localc, GR_COMBINE_OTHER_TEXTURE, FXTRUE); + ctx->Driver.MultipassFunc = fxMultipassBlend; #else - if (MESA_VERBOSE&VERBOSE_DRIVER) - fprintf(stderr,"fx Driver: GL_BLEND not yet supported\n"); -#endif - break; - case GL_REPLACE: - if((ifmt==GL_RGB) || (ifmt==GL_LUMINANCE)) - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - else - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - locala, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - if(ifmt==GL_ALPHA) - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); - else - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - default: - if (MESA_VERBOSE&VERBOSE_DRIVER) - fprintf(stderr, "fx Driver: %x Texture.EnvMode not yet supported\n", - ctx->Texture.Unit[textureset].EnvMode); - break; - } - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupTextureSingleTMU(...) End\n"); - } + if (MESA_VERBOSE & VERBOSE_DRIVER) + fprintf(stderr, "fx Driver: GL_BLEND not yet supported\n"); +#endif + break; + case GL_REPLACE: + if ((ifmt == GL_RGB) || (ifmt == GL_LUMINANCE)) + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + locala, GR_COMBINE_OTHER_NONE, FXFALSE); + else + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_ONE, + locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + + if (ifmt == GL_ALPHA) + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + localc, GR_COMBINE_OTHER_NONE, FXFALSE); + else + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_ONE, + localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + break; + default: + if (MESA_VERBOSE & VERBOSE_DRIVER) + fprintf(stderr, "fx Driver: %x Texture.EnvMode not yet supported\n", + ctx->Texture.Unit[textureset].EnvMode); + break; + } + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupTextureSingleTMU(...) End\n"); + } } -static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) { - BEGIN_BOARD_LOCK(); - fxSetupTextureSingleTMU_NoLock(ctx, textureset); - END_BOARD_LOCK(); +static void +fxSetupTextureSingleTMU(GLcontext * ctx, GLuint textureset) +{ + BEGIN_BOARD_LOCK(); + fxSetupTextureSingleTMU_NoLock(ctx, textureset); + END_BOARD_LOCK(); } /************************* Double Texture Set ***************************/ -static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, - struct gl_texture_object *tObj0, - struct gl_texture_object *tObj1) +static void +fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, + struct gl_texture_object *tObj0, + struct gl_texture_object *tObj1) { #define T0_NOT_IN_TMU 0x01 #define T1_NOT_IN_TMU 0x02 @@ -620,119 +619,130 @@ static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, #define T0_IN_TMU1 0x10 #define T1_IN_TMU1 0x20 - tfxTexInfo *ti0=fxTMGetTexInfo(tObj0); - tfxTexInfo *ti1=fxTMGetTexInfo(tObj1); - GLuint tstate=0; - int tmu0=0, tmu1=1; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupDoubleTMU(...)\n"); - } - - /* We shouldn't need to do this. There is something wrong with - mutlitexturing when the TMUs are swapped. So, we're forcing - them to always be loaded correctly. !!! */ - if (ti0->whichTMU==FX_TMU1) - fxTMMoveOutTM_NoLock(fxMesa, tObj0); - if (ti1->whichTMU==FX_TMU0) - fxTMMoveOutTM_NoLock(fxMesa, tObj1); - - if (ti0->isInTM) { - switch (ti0->whichTMU) { - case FX_TMU0: - tstate|=T0_IN_TMU0; - break; - case FX_TMU1: - tstate|=T0_IN_TMU1; - break; - case FX_TMU_BOTH: - tstate|=T0_IN_TMU0|T0_IN_TMU1; - break; - case FX_TMU_SPLIT: - tstate|=T0_NOT_IN_TMU; - break; - } - } else tstate|=T0_NOT_IN_TMU; - - if (ti1->isInTM) { - switch (ti1->whichTMU) { - case FX_TMU0: - tstate|=T1_IN_TMU0; - break; - case FX_TMU1: - tstate|=T1_IN_TMU1; - break; - case FX_TMU_BOTH: - tstate|=T1_IN_TMU0|T1_IN_TMU1; - break; - case FX_TMU_SPLIT: - tstate|=T1_NOT_IN_TMU; - break; - } - } else tstate|=T1_NOT_IN_TMU; - - ti0->lastTimeUsed=fxMesa->texBindNumber; - ti1->lastTimeUsed=fxMesa->texBindNumber; - - /* Move texture maps into TMUs */ - - if (!(((tstate&T0_IN_TMU0) && (tstate&T1_IN_TMU1)) || - ((tstate&T0_IN_TMU1) && (tstate&T1_IN_TMU0)))) { - if (tObj0==tObj1) fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH); - else { - /* Find the minimal way to correct the situation */ - if ((tstate&T0_IN_TMU0) || (tstate&T1_IN_TMU1)) { - /* We have one in the standard order, setup the other */ - if (tstate&T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */ - fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); - } else { - fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); - } - /* tmu0 and tmu1 are setup */ - } else if ((tstate&T0_IN_TMU1) || (tstate&T1_IN_TMU0)) { - /* we have one in the reverse order, setup the other */ - if (tstate&T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */ - fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1); - } else { - fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0); - } - tmu0=1; - tmu1=0; - } else { /* Nothing is loaded */ - fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); - fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); - /* tmu0 and tmu1 are setup */ + tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0); + tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1); + GLuint tstate = 0; + int tmu0 = 0, tmu1 = 1; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupDoubleTMU(...)\n"); + } + + /* We shouldn't need to do this. There is something wrong with + mutlitexturing when the TMUs are swapped. So, we're forcing + them to always be loaded correctly. !!! */ + if (ti0->whichTMU == FX_TMU1) + fxTMMoveOutTM_NoLock(fxMesa, tObj0); + if (ti1->whichTMU == FX_TMU0) + fxTMMoveOutTM_NoLock(fxMesa, tObj1); + + if (ti0->isInTM) { + switch (ti0->whichTMU) { + case FX_TMU0: + tstate |= T0_IN_TMU0; + break; + case FX_TMU1: + tstate |= T0_IN_TMU1; + break; + case FX_TMU_BOTH: + tstate |= T0_IN_TMU0 | T0_IN_TMU1; + break; + case FX_TMU_SPLIT: + tstate |= T0_NOT_IN_TMU; + break; } - } - } - - if (!fxMesa->haveGlobalPaletteTexture) { - if (ti0->info.format==GR_TEXFMT_P_8) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: uploading texture palette TMU0\n"); - } - FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE, &(ti0->palette)); - } - - if (ti1->info.format==GR_TEXFMT_P_8) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: uploading texture palette TMU1\n"); - } - FX_grTexDownloadTable_NoLock(tmu1, GR_TEXTABLE_PALETTE, &(ti1->palette)); - } - } - - FX_grTexSource_NoLock(tmu0, ti0->tm[tmu0]->startAddr, - GR_MIPMAPLEVELMASK_BOTH, &(ti0->info)); - FX_grTexClampMode_NoLock(tmu0, ti0->sClamp, ti0->tClamp); - FX_grTexFilterMode_NoLock(tmu0, ti0->minFilt, ti0->maxFilt); - FX_grTexMipMapMode_NoLock(tmu0, ti0->mmMode, FXFALSE); - - FX_grTexSource_NoLock(tmu1, ti1->tm[tmu1]->startAddr, - GR_MIPMAPLEVELMASK_BOTH, &(ti1->info)); - FX_grTexClampMode_NoLock(tmu1, ti1->sClamp, ti1->tClamp); - FX_grTexFilterMode_NoLock(tmu1, ti1->minFilt, ti1->maxFilt); - FX_grTexMipMapMode_NoLock(tmu1, ti1->mmMode, FXFALSE); + } + else + tstate |= T0_NOT_IN_TMU; + + if (ti1->isInTM) { + switch (ti1->whichTMU) { + case FX_TMU0: + tstate |= T1_IN_TMU0; + break; + case FX_TMU1: + tstate |= T1_IN_TMU1; + break; + case FX_TMU_BOTH: + tstate |= T1_IN_TMU0 | T1_IN_TMU1; + break; + case FX_TMU_SPLIT: + tstate |= T1_NOT_IN_TMU; + break; + } + } + else + tstate |= T1_NOT_IN_TMU; + + ti0->lastTimeUsed = fxMesa->texBindNumber; + ti1->lastTimeUsed = fxMesa->texBindNumber; + + /* Move texture maps into TMUs */ + + if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) || + ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) { + if (tObj0 == tObj1) + fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH); + else { + /* Find the minimal way to correct the situation */ + if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) { + /* We have one in the standard order, setup the other */ + if (tstate & T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */ + fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); + } + else { + fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); + } + /* tmu0 and tmu1 are setup */ + } + else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) { + /* we have one in the reverse order, setup the other */ + if (tstate & T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */ + fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1); + } + else { + fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0); + } + tmu0 = 1; + tmu1 = 0; + } + else { /* Nothing is loaded */ + fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0); + fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1); + /* tmu0 and tmu1 are setup */ + } + } + } + + if (!fxMesa->haveGlobalPaletteTexture) { + if (ti0->info.format == GR_TEXFMT_P_8) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: uploading texture palette TMU0\n"); + } + FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE, + &(ti0->palette)); + } + + if (ti1->info.format == GR_TEXFMT_P_8) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: uploading texture palette TMU1\n"); + } + FX_grTexDownloadTable_NoLock(tmu1, GR_TEXTABLE_PALETTE, + &(ti1->palette)); + } + } + + FX_grTexSource_NoLock(tmu0, ti0->tm[tmu0]->startAddr, + GR_MIPMAPLEVELMASK_BOTH, &(ti0->info)); + FX_grTexClampMode_NoLock(tmu0, ti0->sClamp, ti0->tClamp); + FX_grTexFilterMode_NoLock(tmu0, ti0->minFilt, ti0->maxFilt); + FX_grTexMipMapMode_NoLock(tmu0, ti0->mmMode, FXFALSE); + + FX_grTexSource_NoLock(tmu1, ti1->tm[tmu1]->startAddr, + GR_MIPMAPLEVELMASK_BOTH, &(ti1->info)); + FX_grTexClampMode_NoLock(tmu1, ti1->sClamp, ti1->tClamp); + FX_grTexFilterMode_NoLock(tmu1, ti1->minFilt, ti1->maxFilt); + FX_grTexMipMapMode_NoLock(tmu1, ti1->mmMode, FXFALSE); #undef T0_NOT_IN_TMU #undef T1_NOT_IN_TMU @@ -742,376 +752,345 @@ static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, #undef T1_IN_TMU1 } -static void fxSetupTextureDoubleTMU_NoLock(GLcontext *ctx) +static void +fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - 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; - GLuint envmode,ifmt,unitsmode; - int tmu0=0, tmu1=1; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupTextureDoubleTMU(...) Start\n"); - } + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + 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; + GLuint envmode, ifmt, unitsmode; + int tmu0 = 0, tmu1 = 1; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupTextureDoubleTMU(...) Start\n"); + } - ti0=fxTMGetTexInfo(tObj0); - fxTexValidate(ctx,tObj0); + ti0 = fxTMGetTexInfo(tObj0); + fxTexValidate(ctx, tObj0); - ti1=fxTMGetTexInfo(tObj1); - fxTexValidate(ctx,tObj1); + ti1 = fxTMGetTexInfo(tObj1); + fxTexValidate(ctx, tObj1); - fxSetupDoubleTMU_NoLock(fxMesa,tObj0,tObj1); + fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1); - unitsmode=fxGetTexSetConfiguration(ctx,tObj0,tObj1); + unitsmode = fxGetTexSetConfiguration(ctx, tObj0, tObj1); /* if(fxMesa->lastUnitsMode==unitsmode) */ /* return; */ - fxMesa->lastUnitsMode=unitsmode; + fxMesa->lastUnitsMode = unitsmode; - fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1; - FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state); + fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1; + FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state); - envmode=unitsmode & FX_UM_E_ENVMODE; - ifmt=unitsmode & FX_UM_E_IFMT; + envmode = unitsmode & FX_UM_E_ENVMODE; + ifmt = unitsmode & FX_UM_E_IFMT; - if(unitsmode & FX_UM_ALPHA_ITERATED) - locala=GR_COMBINE_LOCAL_ITERATED; - else - locala=GR_COMBINE_LOCAL_CONSTANT; + if (unitsmode & FX_UM_ALPHA_ITERATED) + locala = GR_COMBINE_LOCAL_ITERATED; + else + locala = GR_COMBINE_LOCAL_CONSTANT; - if(unitsmode & FX_UM_COLOR_ITERATED) - localc=GR_COMBINE_LOCAL_ITERATED; - else - localc=GR_COMBINE_LOCAL_CONSTANT; + if (unitsmode & FX_UM_COLOR_ITERATED) + localc = GR_COMBINE_LOCAL_ITERATED; + else + localc = GR_COMBINE_LOCAL_CONSTANT; - if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) - fprintf(stderr, "fxMesa: fxSetupTextureDoubleTMU, envmode is %s/%s\n", - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), - _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); + if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) + fprintf(stderr, "fxMesa: fxSetupTextureDoubleTMU, envmode is %s/%s\n", + _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), + _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); - if ((ti0->whichTMU==FX_TMU1) || (ti1->whichTMU==FX_TMU0)) { - tmu0=1; - tmu1=0; - } - fxMesa->tmuSrc=FX_TMU_BOTH; - switch(envmode) { - case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE): - { - GLboolean isalpha[FX_NUM_TMU]; - - if(ti0->baseLevelInternalFormat==GL_ALPHA) - isalpha[tmu0]=GL_TRUE; - else - isalpha[tmu0]=GL_FALSE; + if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) { + tmu0 = 1; + tmu1 = 0; + } + fxMesa->tmuSrc = FX_TMU_BOTH; + switch (envmode) { + case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE): + { + GLboolean isalpha[FX_NUM_TMU]; + + if (ti0->baseLevelInternalFormat == GL_ALPHA) + isalpha[tmu0] = GL_TRUE; + else + isalpha[tmu0] = GL_FALSE; + + if (ti1->baseLevelInternalFormat == GL_ALPHA) + isalpha[tmu1] = GL_TRUE; + else + isalpha[tmu1] = GL_FALSE; + + if (isalpha[FX_TMU1]) + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXTRUE, FXFALSE); + else + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + + if (isalpha[FX_TMU0]) + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_ONE, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE); + else + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE); + + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_LOCAL, + localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_LOCAL, + locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + break; + } + case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */ + if (tmu1 == FX_TMU1) { + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXTRUE, FXFALSE); + + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE); + } + else { + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_ONE_MINUS_LOCAL, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_ONE_MINUS_LOCAL, + FXFALSE, FXFALSE); + } - if(ti1->baseLevelInternalFormat==GL_ALPHA) - isalpha[tmu1]=GL_TRUE; - else - isalpha[tmu1]=GL_FALSE; - - if(isalpha[FX_TMU1]) - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_ZERO, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXTRUE,FXFALSE); - else - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - - if(isalpha[FX_TMU0]) - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - FXFALSE,FXFALSE); - else - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - FXFALSE,FXFALSE); + locala, GR_COMBINE_OTHER_NONE, FXFALSE); FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - locala, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - } - case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */ - if (tmu1==FX_TMU1) { - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXTRUE,FXFALSE); - - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - FXFALSE,FXFALSE); - } else { - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_ONE_MINUS_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_ONE_MINUS_LOCAL, - FXFALSE,FXFALSE); - } - - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */ - if (tmu1==FX_TMU1) { - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_ZERO, - GR_COMBINE_FACTOR_NONE, - FXFALSE,FXTRUE); - - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - FXFALSE,FXFALSE); - - } else { - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_LOCAL, - GR_COMBINE_FUNCTION_BLEND_OTHER, - GR_COMBINE_FACTOR_ONE, - FXFALSE,FXFALSE); - } - - if(ti0->baseLevelInternalFormat==GL_RGB) - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - else - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - + localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + break; + case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */ + if (tmu1 == FX_TMU1) { + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXTRUE); + + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, FXFALSE, FXFALSE); - case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */ - { - GLboolean isalpha[FX_NUM_TMU]; + } + else { + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_LOCAL, + GR_COMBINE_FUNCTION_BLEND_OTHER, + GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE); + } - if(ti0->baseLevelInternalFormat==GL_ALPHA) - isalpha[tmu0]=GL_TRUE; + if (ti0->baseLevelInternalFormat == GL_RGB) + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + locala, GR_COMBINE_OTHER_NONE, FXFALSE); else - isalpha[tmu0]=GL_FALSE; + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_ONE, + locala, GR_COMBINE_OTHER_NONE, FXFALSE); - if(ti1->baseLevelInternalFormat==GL_ALPHA) - isalpha[tmu1]=GL_TRUE; - else - isalpha[tmu1]=GL_FALSE; - - if(isalpha[FX_TMU1]) - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_ZERO, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXTRUE,FXFALSE); - else - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); - if(isalpha[FX_TMU0]) - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, - GR_COMBINE_FACTOR_ONE, - FXFALSE,FXFALSE); - else - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, - FXFALSE,FXFALSE); + localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + break; - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - localc, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_LOCAL, - locala, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - } - default: - fprintf(stderr, "Unexpected dual texture mode encountered\n"); - break; - } - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupTextureDoubleTMU(...) End\n"); - } + case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */ + { + GLboolean isalpha[FX_NUM_TMU]; + + if (ti0->baseLevelInternalFormat == GL_ALPHA) + isalpha[tmu0] = GL_TRUE; + else + isalpha[tmu0] = GL_FALSE; + + if (ti1->baseLevelInternalFormat == GL_ALPHA) + isalpha[tmu1] = GL_TRUE; + else + isalpha[tmu1] = GL_FALSE; + + if (isalpha[FX_TMU1]) + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_ZERO, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXTRUE, FXFALSE); + else + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); + + if (isalpha[FX_TMU0]) + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_ONE, + GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, + GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE); + else + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, + GR_COMBINE_FACTOR_ONE, + GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL, + GR_COMBINE_FACTOR_ONE, FXFALSE, FXFALSE); + + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_LOCAL, + localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, + GR_COMBINE_FACTOR_LOCAL, + locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE); + break; + } + default: + fprintf(stderr, "Unexpected dual texture mode encountered\n"); + break; + } + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupTextureDoubleTMU(...) End\n"); + } } /************************* No Texture ***************************/ -static void fxSetupTextureNone_NoLock(GLcontext *ctx) +static void +fxSetupTextureNone_NoLock(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GrCombineLocal_t localc,locala; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupTextureNone(...)\n"); - } - - if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 || - (ctx->Point.SmoothFlag) || - (ctx->Line.SmoothFlag) || - (ctx->Polygon.SmoothFlag)) - locala=GR_COMBINE_LOCAL_ITERATED; - else - locala=GR_COMBINE_LOCAL_CONSTANT; - - if(ctx->Light.ShadeModel==GL_SMOOTH || 1) - localc=GR_COMBINE_LOCAL_ITERATED; - else - localc=GR_COMBINE_LOCAL_CONSTANT; - - FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - locala, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - localc, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - fxMesa->lastUnitsMode=FX_UM_NONE; + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + GrCombineLocal_t localc, locala; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupTextureNone(...)\n"); + } + + if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 || + (ctx->Point.SmoothFlag) || + (ctx->Line.SmoothFlag) || + (ctx->Polygon.SmoothFlag)) locala = GR_COMBINE_LOCAL_ITERATED; + else + locala = GR_COMBINE_LOCAL_CONSTANT; + + if (ctx->Light.ShadeModel == GL_SMOOTH || 1) + localc = GR_COMBINE_LOCAL_ITERATED; + else + localc = GR_COMBINE_LOCAL_CONSTANT; + + FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + locala, GR_COMBINE_OTHER_NONE, FXFALSE); + + FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL, + GR_COMBINE_FACTOR_NONE, + localc, GR_COMBINE_OTHER_NONE, FXFALSE); + + fxMesa->lastUnitsMode = FX_UM_NONE; } /************************************************************************/ /************************** Texture Mode SetUp **************************/ /************************************************************************/ -static void fxSetupTexture_NoLock(GLcontext *ctx) +static void +fxSetupTexture_NoLock(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLuint tex2Denabled; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupTexture(...)\n"); - } - - /* Disable multipass texturing. - */ - ctx->Driver.MultipassFunc = 0; - - /* Texture Combine, Color Combine and Alpha Combine. - */ - tex2Denabled = (ctx->Texture._ReallyEnabled & TEXTURE0_2D); - - if (fxMesa->emulateTwoTMUs) - tex2Denabled |= (ctx->Texture._ReallyEnabled & TEXTURE1_2D); - - switch(tex2Denabled) { - case TEXTURE0_2D: - fxSetupTextureSingleTMU_NoLock(ctx,0); - break; - case TEXTURE1_2D: - fxSetupTextureSingleTMU_NoLock(ctx,1); - break; - case (TEXTURE0_2D|TEXTURE1_2D): - if (fxMesa->haveTwoTMUs) - fxSetupTextureDoubleTMU_NoLock(ctx); - else { - if (MESA_VERBOSE&VERBOSE_DRIVER) - fprintf(stderr, "fxmesa: enabling fake multitexture\n"); - - fxSetupTextureSingleTMU_NoLock(ctx,0); - ctx->Driver.MultipassFunc = fxMultipassTexture; - } - break; - default: - fxSetupTextureNone_NoLock(ctx); - break; - } + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + GLuint tex2Denabled; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupTexture(...)\n"); + } + + /* Disable multipass texturing. + */ + ctx->Driver.MultipassFunc = 0; + + /* Texture Combine, Color Combine and Alpha Combine. + */ + tex2Denabled = (ctx->Texture._ReallyEnabled & TEXTURE0_2D); + + if (fxMesa->emulateTwoTMUs) + tex2Denabled |= (ctx->Texture._ReallyEnabled & TEXTURE1_2D); + + switch (tex2Denabled) { + case TEXTURE0_2D: + fxSetupTextureSingleTMU_NoLock(ctx, 0); + break; + case TEXTURE1_2D: + fxSetupTextureSingleTMU_NoLock(ctx, 1); + break; + case (TEXTURE0_2D | TEXTURE1_2D): + if (fxMesa->haveTwoTMUs) + fxSetupTextureDoubleTMU_NoLock(ctx); + else { + if (MESA_VERBOSE & VERBOSE_DRIVER) + fprintf(stderr, "fxmesa: enabling fake multitexture\n"); + + fxSetupTextureSingleTMU_NoLock(ctx, 0); + ctx->Driver.MultipassFunc = fxMultipassTexture; + } + break; + default: + fxSetupTextureNone_NoLock(ctx); + break; + } } -static void fxSetupTexture(GLcontext *ctx) { - BEGIN_BOARD_LOCK(); - fxSetupTexture_NoLock(ctx); - END_BOARD_LOCK(); +static void +fxSetupTexture(GLcontext * ctx) +{ + BEGIN_BOARD_LOCK(); + fxSetupTexture_NoLock(ctx); + END_BOARD_LOCK(); } /************************************************************************/ @@ -1119,302 +1098,313 @@ static void fxSetupTexture(GLcontext *ctx) { /************************************************************************/ /* XXX consider supporting GL_INGR_blend_func_separate */ -void fxDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor) +void +fxDDBlendFunc(GLcontext * ctx, GLenum sfactor, GLenum dfactor) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - GrAlphaBlendFnc_t sfact,dfact,asfact,adfact; - - /* From the Glide documentation: - For alpha source and destination blend function factor - parameters, Voodoo Graphics supports only - GR_BLEND_ZERO and GR_BLEND_ONE. - */ - - switch(sfactor) { - case GL_ZERO: - asfact=sfact=GR_BLEND_ZERO; - break; - case GL_ONE: - asfact=sfact=GR_BLEND_ONE; - break; - case GL_DST_COLOR: - sfact=GR_BLEND_DST_COLOR; - asfact=GR_BLEND_ONE; - break; - case GL_ONE_MINUS_DST_COLOR: - sfact=GR_BLEND_ONE_MINUS_DST_COLOR; - asfact=GR_BLEND_ONE; - break; - case GL_SRC_ALPHA: - sfact=GR_BLEND_SRC_ALPHA; - asfact=GR_BLEND_ONE; - break; - case GL_ONE_MINUS_SRC_ALPHA: - sfact=GR_BLEND_ONE_MINUS_SRC_ALPHA; - asfact=GR_BLEND_ONE; - break; - case GL_DST_ALPHA: - sfact=GR_BLEND_DST_ALPHA; - asfact=GR_BLEND_ONE; - break; - case GL_ONE_MINUS_DST_ALPHA: - sfact=GR_BLEND_ONE_MINUS_DST_ALPHA; - asfact=GR_BLEND_ONE; - break; - case GL_SRC_ALPHA_SATURATE: - sfact=GR_BLEND_ALPHA_SATURATE; - asfact=GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - case GL_ONE_MINUS_SRC_COLOR: - /* USELESS */ - asfact=sfact=GR_BLEND_ONE; - break; - default: - asfact=sfact=GR_BLEND_ONE; - break; - } - - if((sfact!=us->blendSrcFuncRGB) || - (asfact!=us->blendSrcFuncAlpha)) { - us->blendSrcFuncRGB=sfact; - us->blendSrcFuncAlpha=asfact; - fxMesa->new_state |= FX_NEW_BLEND; - } - - switch(dfactor) { - case GL_ZERO: - adfact=dfact=GR_BLEND_ZERO; - break; - case GL_ONE: - adfact=dfact=GR_BLEND_ONE; - break; - case GL_SRC_COLOR: - dfact=GR_BLEND_SRC_COLOR; - adfact=GR_BLEND_ZERO; - break; - case GL_ONE_MINUS_SRC_COLOR: - dfact=GR_BLEND_ONE_MINUS_SRC_COLOR; - adfact=GR_BLEND_ZERO; - break; - case GL_SRC_ALPHA: - dfact=GR_BLEND_SRC_ALPHA; - adfact=GR_BLEND_ZERO; - break; - case GL_ONE_MINUS_SRC_ALPHA: - dfact=GR_BLEND_ONE_MINUS_SRC_ALPHA; - adfact=GR_BLEND_ZERO; - break; - case GL_DST_ALPHA: - /* dfact=GR_BLEND_DST_ALPHA; */ - /* We can't do DST_ALPHA */ - dfact=GR_BLEND_ONE; - adfact=GR_BLEND_ZERO; - break; - case GL_ONE_MINUS_DST_ALPHA: - /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */ - /* We can't do DST_ALPHA */ - dfact=GR_BLEND_ZERO; - adfact=GR_BLEND_ZERO; - break; - case GL_SRC_ALPHA_SATURATE: - case GL_DST_COLOR: - case GL_ONE_MINUS_DST_COLOR: - /* USELESS */ - adfact=dfact=GR_BLEND_ZERO; - break; - default: - adfact=dfact=GR_BLEND_ZERO; - break; - } - - if((dfact!=us->blendDstFuncRGB) || - (adfact!=us->blendDstFuncAlpha)) { - us->blendDstFuncRGB=dfact; - us->blendDstFuncAlpha=adfact; - fxMesa->new_state |= FX_NEW_BLEND; - } + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; + GrAlphaBlendFnc_t sfact, dfact, asfact, adfact; + + /* From the Glide documentation: + For alpha source and destination blend function factor + parameters, Voodoo Graphics supports only + GR_BLEND_ZERO and GR_BLEND_ONE. + */ + + switch (sfactor) { + case GL_ZERO: + asfact = sfact = GR_BLEND_ZERO; + break; + case GL_ONE: + asfact = sfact = GR_BLEND_ONE; + break; + case GL_DST_COLOR: + sfact = GR_BLEND_DST_COLOR; + asfact = GR_BLEND_ONE; + break; + case GL_ONE_MINUS_DST_COLOR: + sfact = GR_BLEND_ONE_MINUS_DST_COLOR; + asfact = GR_BLEND_ONE; + break; + case GL_SRC_ALPHA: + sfact = GR_BLEND_SRC_ALPHA; + asfact = GR_BLEND_ONE; + break; + case GL_ONE_MINUS_SRC_ALPHA: + sfact = GR_BLEND_ONE_MINUS_SRC_ALPHA; + asfact = GR_BLEND_ONE; + break; + case GL_DST_ALPHA: + sfact = GR_BLEND_DST_ALPHA; + asfact = GR_BLEND_ONE; + break; + case GL_ONE_MINUS_DST_ALPHA: + sfact = GR_BLEND_ONE_MINUS_DST_ALPHA; + asfact = GR_BLEND_ONE; + break; + case GL_SRC_ALPHA_SATURATE: + sfact = GR_BLEND_ALPHA_SATURATE; + asfact = GR_BLEND_ONE; + break; + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + /* USELESS */ + asfact = sfact = GR_BLEND_ONE; + break; + default: + asfact = sfact = GR_BLEND_ONE; + break; + } + + if ((sfact != us->blendSrcFuncRGB) || (asfact != us->blendSrcFuncAlpha)) { + us->blendSrcFuncRGB = sfact; + us->blendSrcFuncAlpha = asfact; + fxMesa->new_state |= FX_NEW_BLEND; + } + + switch (dfactor) { + case GL_ZERO: + adfact = dfact = GR_BLEND_ZERO; + break; + case GL_ONE: + adfact = dfact = GR_BLEND_ONE; + break; + case GL_SRC_COLOR: + dfact = GR_BLEND_SRC_COLOR; + adfact = GR_BLEND_ZERO; + break; + case GL_ONE_MINUS_SRC_COLOR: + dfact = GR_BLEND_ONE_MINUS_SRC_COLOR; + adfact = GR_BLEND_ZERO; + break; + case GL_SRC_ALPHA: + dfact = GR_BLEND_SRC_ALPHA; + adfact = GR_BLEND_ZERO; + break; + case GL_ONE_MINUS_SRC_ALPHA: + dfact = GR_BLEND_ONE_MINUS_SRC_ALPHA; + adfact = GR_BLEND_ZERO; + break; + case GL_DST_ALPHA: + /* dfact=GR_BLEND_DST_ALPHA; */ + /* We can't do DST_ALPHA */ + dfact = GR_BLEND_ONE; + adfact = GR_BLEND_ZERO; + break; + case GL_ONE_MINUS_DST_ALPHA: + /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */ + /* We can't do DST_ALPHA */ + dfact = GR_BLEND_ZERO; + adfact = GR_BLEND_ZERO; + break; + case GL_SRC_ALPHA_SATURATE: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + /* USELESS */ + adfact = dfact = GR_BLEND_ZERO; + break; + default: + adfact = dfact = GR_BLEND_ZERO; + break; + } + + if ((dfact != us->blendDstFuncRGB) || (adfact != us->blendDstFuncAlpha)) { + us->blendDstFuncRGB = dfact; + us->blendDstFuncAlpha = adfact; + fxMesa->new_state |= FX_NEW_BLEND; + } } -static void fxSetupBlend(GLcontext *ctx) +static void +fxSetupBlend(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - - if(us->blendEnabled) - FX_grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB, - us->blendSrcFuncAlpha,us->blendDstFuncAlpha); - else - FX_grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO); + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; + + if (us->blendEnabled) + FX_grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB, + us->blendSrcFuncAlpha, us->blendDstFuncAlpha); + else + FX_grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, + GR_BLEND_ZERO); } - + /************************************************************************/ /************************** Alpha Test SetUp ****************************/ /************************************************************************/ -void fxDDAlphaFunc(GLcontext *ctx, GLenum func, GLchan ref) +void +fxDDAlphaFunc(GLcontext * ctx, GLenum func, GLchan ref) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - GrCmpFnc_t newfunc; - - switch(func) { - case GL_NEVER: - newfunc=GR_CMP_NEVER; - break; - case GL_LESS: - newfunc=GR_CMP_LESS; - break; - case GL_EQUAL: - newfunc=GR_CMP_EQUAL; - break; - case GL_LEQUAL: - newfunc=GR_CMP_LEQUAL; - break; - case GL_GREATER: - newfunc=GR_CMP_GREATER; - break; - case GL_NOTEQUAL: - newfunc=GR_CMP_NOTEQUAL; - break; - case GL_GEQUAL: - newfunc=GR_CMP_GEQUAL; - break; - case GL_ALWAYS: - newfunc=GR_CMP_ALWAYS; - break; - default: - fprintf(stderr,"fx Driver: internal error in fxDDAlphaFunc()\n"); - fxCloseHardware(); - exit(-1); - break; - } - - if(newfunc!=us->alphaTestFunc) { - us->alphaTestFunc=newfunc; - fxMesa->new_state |= FX_NEW_ALPHA; - } - - if (ref != us->alphaTestRefValue) { - us->alphaTestRefValue = ref; - fxMesa->new_state |= FX_NEW_ALPHA; - } + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; + GrCmpFnc_t newfunc; + + switch (func) { + case GL_NEVER: + newfunc = GR_CMP_NEVER; + break; + case GL_LESS: + newfunc = GR_CMP_LESS; + break; + case GL_EQUAL: + newfunc = GR_CMP_EQUAL; + break; + case GL_LEQUAL: + newfunc = GR_CMP_LEQUAL; + break; + case GL_GREATER: + newfunc = GR_CMP_GREATER; + break; + case GL_NOTEQUAL: + newfunc = GR_CMP_NOTEQUAL; + break; + case GL_GEQUAL: + newfunc = GR_CMP_GEQUAL; + break; + case GL_ALWAYS: + newfunc = GR_CMP_ALWAYS; + break; + default: + fprintf(stderr, "fx Driver: internal error in fxDDAlphaFunc()\n"); + fxCloseHardware(); + exit(-1); + break; + } + + if (newfunc != us->alphaTestFunc) { + us->alphaTestFunc = newfunc; + fxMesa->new_state |= FX_NEW_ALPHA; + } + + if (ref != us->alphaTestRefValue) { + us->alphaTestRefValue = ref; + fxMesa->new_state |= FX_NEW_ALPHA; + } } -static void fxSetupAlphaTest(GLcontext *ctx) +static void +fxSetupAlphaTest(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - - if(us->alphaTestEnabled) { - FX_grAlphaTestFunction(us->alphaTestFunc); - FX_grAlphaTestReferenceValue(us->alphaTestRefValue); - } else - FX_grAlphaTestFunction(GR_CMP_ALWAYS); + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; + + if (us->alphaTestEnabled) { + FX_grAlphaTestFunction(us->alphaTestFunc); + FX_grAlphaTestReferenceValue(us->alphaTestRefValue); + } + else + FX_grAlphaTestFunction(GR_CMP_ALWAYS); } /************************************************************************/ /************************** Depth Test SetUp ****************************/ /************************************************************************/ -void fxDDDepthFunc(GLcontext *ctx, GLenum func) +void +fxDDDepthFunc(GLcontext * ctx, GLenum func) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - GrCmpFnc_t dfunc; - - switch(func) { - case GL_NEVER: - dfunc=GR_CMP_NEVER; - break; - case GL_LESS: - dfunc=GR_CMP_LESS; - break; - case GL_GEQUAL: - dfunc=GR_CMP_GEQUAL; - break; - case GL_LEQUAL: - dfunc=GR_CMP_LEQUAL; - break; - case GL_GREATER: - dfunc=GR_CMP_GREATER; - break; - case GL_NOTEQUAL: - dfunc=GR_CMP_NOTEQUAL; - break; - case GL_EQUAL: - dfunc=GR_CMP_EQUAL; - break; - case GL_ALWAYS: - dfunc=GR_CMP_ALWAYS; - break; - default: - fprintf(stderr,"fx Driver: internal error in fxDDDepthFunc()\n"); - fxCloseHardware(); - exit(-1); - break; - } - - if(dfunc!=us->depthTestFunc) { - us->depthTestFunc=dfunc; - fxMesa->new_state |= FX_NEW_DEPTH; - } + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; + GrCmpFnc_t dfunc; + + switch (func) { + case GL_NEVER: + dfunc = GR_CMP_NEVER; + break; + case GL_LESS: + dfunc = GR_CMP_LESS; + break; + case GL_GEQUAL: + dfunc = GR_CMP_GEQUAL; + break; + case GL_LEQUAL: + dfunc = GR_CMP_LEQUAL; + break; + case GL_GREATER: + dfunc = GR_CMP_GREATER; + break; + case GL_NOTEQUAL: + dfunc = GR_CMP_NOTEQUAL; + break; + case GL_EQUAL: + dfunc = GR_CMP_EQUAL; + break; + case GL_ALWAYS: + dfunc = GR_CMP_ALWAYS; + break; + default: + fprintf(stderr, "fx Driver: internal error in fxDDDepthFunc()\n"); + fxCloseHardware(); + exit(-1); + break; + } + + if (dfunc != us->depthTestFunc) { + us->depthTestFunc = dfunc; + fxMesa->new_state |= FX_NEW_DEPTH; + } } -void fxDDDepthMask(GLcontext *ctx, GLboolean flag) +void +fxDDDepthMask(GLcontext * ctx, GLboolean flag) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; - if(flag!=us->depthMask) { - us->depthMask=flag; - fxMesa->new_state |= FX_NEW_DEPTH; - } + if (flag != us->depthMask) { + us->depthMask = flag; + fxMesa->new_state |= FX_NEW_DEPTH; + } } -static void fxSetupDepthTest(GLcontext *ctx) +static void +fxSetupDepthTest(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - - if (us->depthTestEnabled) { - FX_grDepthBufferFunction(us->depthTestFunc); - FX_grDepthMask(us->depthMask); - } - else { - FX_grDepthBufferFunction(GR_CMP_ALWAYS); - FX_grDepthMask(FXFALSE); - } + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; + + if (us->depthTestEnabled) { + FX_grDepthBufferFunction(us->depthTestFunc); + FX_grDepthMask(us->depthMask); + } + else { + FX_grDepthBufferFunction(GR_CMP_ALWAYS); + FX_grDepthMask(FXFALSE); + } } /************************************************************************/ /**************************** Color Mask SetUp **************************/ /************************************************************************/ -void fxDDColorMask(GLcontext *ctx, - GLboolean r, GLboolean g, - GLboolean b, GLboolean a ) +void +fxDDColorMask(GLcontext * ctx, + GLboolean r, GLboolean g, GLboolean b, GLboolean a) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - fxMesa->new_state |= FX_NEW_COLOR_MASK; - (void) r; (void) g; (void) b; (void) a; + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + fxMesa->new_state |= FX_NEW_COLOR_MASK; + (void) r; + (void) g; + (void) b; + (void) a; } -static void fxSetupColorMask(GLcontext *ctx) +static void +fxSetupColorMask(GLcontext * ctx) { - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - if (ctx->Color.DrawBuffer == GL_NONE) { - FX_grColorMask(FXFALSE, FXFALSE); - } - else { - FX_grColorMask(ctx->Color.ColorMask[RCOMP] || - ctx->Color.ColorMask[GCOMP] || - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); - } + fxMesaContext fxMesa = FX_CONTEXT(ctx); + + if (ctx->Color.DrawBuffer == GL_NONE) { + FX_grColorMask(FXFALSE, FXFALSE); + } + else { + FX_grColorMask(ctx->Color.ColorMask[RCOMP] || + ctx->Color.ColorMask[GCOMP] || + ctx->Color.ColorMask[BCOMP], + ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); + } } @@ -1427,52 +1417,55 @@ static void fxSetupColorMask(GLcontext *ctx) /* * This is called during state update in order to update the Glide fog state. */ -static void fxSetupFog(GLcontext *ctx) +static void +fxSetupFog(GLcontext * ctx) { - if (ctx->Fog.Enabled /*&& ctx->FogMode==FOG_FRAGMENT*/) { - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - /* update fog color */ - GLubyte col[4]; - col[0]=(unsigned int)(255*ctx->Fog.Color[0]); - col[1]=(unsigned int)(255*ctx->Fog.Color[1]); - col[2]=(unsigned int)(255*ctx->Fog.Color[2]); - col[3]=(unsigned int)(255*ctx->Fog.Color[3]); - FX_grFogColorValue(FXCOLOR4(col)); - - if(fxMesa->fogTableMode != ctx->Fog.Mode || - fxMesa->fogDensity != ctx->Fog.Density || - fxMesa->fogStart != ctx->Fog.Start || - fxMesa->fogEnd != ctx->Fog.End) { - /* reload the fog table */ - switch (ctx->Fog.Mode) { - case GL_LINEAR: - guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start, ctx->Fog.End); - break; - case GL_EXP: - guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density); - break; - case GL_EXP2: - guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density); - break; - default: - ; + if (ctx->Fog.Enabled /*&& ctx->FogMode==FOG_FRAGMENT */ ) { + fxMesaContext fxMesa = FX_CONTEXT(ctx); + + /* update fog color */ + GLubyte col[4]; + col[0] = (unsigned int) (255 * ctx->Fog.Color[0]); + col[1] = (unsigned int) (255 * ctx->Fog.Color[1]); + col[2] = (unsigned int) (255 * ctx->Fog.Color[2]); + col[3] = (unsigned int) (255 * ctx->Fog.Color[3]); + FX_grFogColorValue(FXCOLOR4(col)); + + if (fxMesa->fogTableMode != ctx->Fog.Mode || + fxMesa->fogDensity != ctx->Fog.Density || + fxMesa->fogStart != ctx->Fog.Start || + fxMesa->fogEnd != ctx->Fog.End) { + /* reload the fog table */ + switch (ctx->Fog.Mode) { + case GL_LINEAR: + guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start, + ctx->Fog.End); + break; + case GL_EXP: + guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density); + break; + case GL_EXP2: + guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density); + break; + default: + ; + } + fxMesa->fogTableMode = ctx->Fog.Mode; + fxMesa->fogDensity = ctx->Fog.Density; + fxMesa->fogStart = ctx->Fog.Start; + fxMesa->fogEnd = ctx->Fog.End; } - fxMesa->fogTableMode = ctx->Fog.Mode; - fxMesa->fogDensity = ctx->Fog.Density; - fxMesa->fogStart = ctx->Fog.Start; - fxMesa->fogEnd = ctx->Fog.End; - } - - FX_grFogTable(fxMesa->fogTable); - FX_grFogMode(GR_FOG_WITH_TABLE); - } - else { - FX_grFogMode(GR_FOG_DISABLE); - } + + FX_grFogTable(fxMesa->fogTable); + FX_grFogMode(GR_FOG_WITH_TABLE); + } + else { + FX_grFogMode(GR_FOG_DISABLE); + } } -void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) +void +fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params) { FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG; } @@ -1482,42 +1475,48 @@ void fxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params ) /************************************************************************/ /* This routine is used in managing the lock state, and therefore can't lock */ -void fxSetScissorValues(GLcontext *ctx) +void +fxSetScissorValues(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - int xmin, xmax; - int ymin, ymax, check; - - if (ctx->Scissor.Enabled) { - xmin=ctx->Scissor.X; - xmax=ctx->Scissor.X+ctx->Scissor.Width; - ymin=ctx->Scissor.Y; - ymax=ctx->Scissor.Y+ctx->Scissor.Height; - check=1; - } else { - xmin=0; - ymin=0; - xmax=fxMesa->width; - ymax=fxMesa->height; - check=0; - } - if (xmin<fxMesa->clipMinX) xmin=fxMesa->clipMinX; - if (xmax>fxMesa->clipMaxX) xmax=fxMesa->clipMaxX; - if (ymin<fxMesa->screen_height-fxMesa->clipMaxY) - ymin=fxMesa->screen_height-fxMesa->clipMaxY; - if (ymax>fxMesa->screen_height-fxMesa->clipMinY) - ymax=fxMesa->screen_height-fxMesa->clipMinY; - FX_grClipWindow_NoLock(xmin, ymin, xmax, ymax); + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + int xmin, xmax; + int ymin, ymax, check; + + if (ctx->Scissor.Enabled) { + xmin = ctx->Scissor.X; + xmax = ctx->Scissor.X + ctx->Scissor.Width; + ymin = ctx->Scissor.Y; + ymax = ctx->Scissor.Y + ctx->Scissor.Height; + check = 1; + } + else { + xmin = 0; + ymin = 0; + xmax = fxMesa->width; + ymax = fxMesa->height; + check = 0; + } + if (xmin < fxMesa->clipMinX) + xmin = fxMesa->clipMinX; + if (xmax > fxMesa->clipMaxX) + xmax = fxMesa->clipMaxX; + if (ymin < fxMesa->screen_height - fxMesa->clipMaxY) + ymin = fxMesa->screen_height - fxMesa->clipMaxY; + if (ymax > fxMesa->screen_height - fxMesa->clipMinY) + ymax = fxMesa->screen_height - fxMesa->clipMinY; + FX_grClipWindow_NoLock(xmin, ymin, xmax, ymax); } -static void fxSetupScissor(GLcontext *ctx) +static void +fxSetupScissor(GLcontext * ctx) { - BEGIN_BOARD_LOCK(); - fxSetScissorValues(ctx); - END_BOARD_LOCK(); + BEGIN_BOARD_LOCK(); + fxSetScissorValues(ctx); + END_BOARD_LOCK(); } -void fxDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) +void +fxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) { FX_CONTEXT(ctx)->new_state |= FX_NEW_SCISSOR; } @@ -1527,44 +1526,49 @@ void fxDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) /************************************************************************/ -void fxDDCullFace(GLcontext *ctx, GLenum mode) +void +fxDDCullFace(GLcontext * ctx, GLenum mode) { (void) mode; FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL; } -void fxDDFrontFace(GLcontext *ctx, GLenum mode) +void +fxDDFrontFace(GLcontext * ctx, GLenum mode) { (void) mode; FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL; } -static void fxSetupCull(GLcontext *ctx) +static void +fxSetupCull(GLcontext * ctx) { - if (ctx->Polygon.CullFlag) { - switch (ctx->Polygon.CullFaceMode) { - case GL_BACK: - if (ctx->Polygon.FrontFace==GL_CCW) - FX_CONTEXT(ctx)->cullMode=GR_CULL_NEGATIVE; - else - FX_CONTEXT(ctx)->cullMode=GR_CULL_POSITIVE; - break; - case GL_FRONT: - if(ctx->Polygon.FrontFace==GL_CCW) - FX_CONTEXT(ctx)->cullMode=GR_CULL_POSITIVE; - else - FX_CONTEXT(ctx)->cullMode=GR_CULL_NEGATIVE; - break; - case GL_FRONT_AND_BACK: - FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE; - break; - default: - break; - } - } else FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE; + if (ctx->Polygon.CullFlag) { + switch (ctx->Polygon.CullFaceMode) { + case GL_BACK: + if (ctx->Polygon.FrontFace == GL_CCW) + FX_CONTEXT(ctx)->cullMode = GR_CULL_NEGATIVE; + else + FX_CONTEXT(ctx)->cullMode = GR_CULL_POSITIVE; + break; + case GL_FRONT: + if (ctx->Polygon.FrontFace == GL_CCW) + FX_CONTEXT(ctx)->cullMode = GR_CULL_POSITIVE; + else + FX_CONTEXT(ctx)->cullMode = GR_CULL_NEGATIVE; + break; + case GL_FRONT_AND_BACK: + FX_CONTEXT(ctx)->cullMode = GR_CULL_DISABLE; + break; + default: + break; + } + } + else + FX_CONTEXT(ctx)->cullMode = GR_CULL_DISABLE; - FX_grCullMode(FX_CONTEXT(ctx)->cullMode); + FX_grCullMode(FX_CONTEXT(ctx)->cullMode); } @@ -1572,63 +1576,65 @@ static void fxSetupCull(GLcontext *ctx) /****************************** DD Enable ******************************/ /************************************************************************/ -void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state) +void +fxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + tfxUnitsState *us = &fxMesa->unitsState; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDEnable(...)\n"); - } + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDEnable(...)\n"); + } - switch(cap) { - case GL_ALPHA_TEST: - if(state!=us->alphaTestEnabled) { - us->alphaTestEnabled=state; - fxMesa->new_state |= FX_NEW_ALPHA; - } - break; - case GL_BLEND: - if(state!=us->blendEnabled) { - us->blendEnabled=state; - fxMesa->new_state |= FX_NEW_BLEND; - } - break; - case GL_DEPTH_TEST: - if(state!=us->depthTestEnabled) { - us->depthTestEnabled=state; - fxMesa->new_state |= FX_NEW_DEPTH; - } - break; - case GL_DITHER: - if (state) { - FX_grDitherMode(GR_DITHER_4x4); - } else { - FX_grDitherMode(GR_DITHER_DISABLE); - } - break; - case GL_SCISSOR_TEST: - fxMesa->new_state |= FX_NEW_SCISSOR; - break; - case GL_SHARED_TEXTURE_PALETTE_EXT: - fxDDTexUseGlbPalette(ctx, state); - break; - case GL_FOG: - fxMesa->new_state |= FX_NEW_FOG; - break; - case GL_CULL_FACE: - fxMesa->new_state |= FX_NEW_CULL; - break; - case GL_LINE_SMOOTH: - case GL_LINE_STIPPLE: - case GL_POINT_SMOOTH: - case GL_POLYGON_SMOOTH: - case GL_TEXTURE_2D: + switch (cap) { + case GL_ALPHA_TEST: + if (state != us->alphaTestEnabled) { + us->alphaTestEnabled = state; + fxMesa->new_state |= FX_NEW_ALPHA; + } + break; + case GL_BLEND: + if (state != us->blendEnabled) { + us->blendEnabled = state; + fxMesa->new_state |= FX_NEW_BLEND; + } + break; + case GL_DEPTH_TEST: + if (state != us->depthTestEnabled) { + us->depthTestEnabled = state; + fxMesa->new_state |= FX_NEW_DEPTH; + } + break; + case GL_DITHER: + if (state) { + FX_grDitherMode(GR_DITHER_4x4); + } + else { + FX_grDitherMode(GR_DITHER_DISABLE); + } + break; + case GL_SCISSOR_TEST: + fxMesa->new_state |= FX_NEW_SCISSOR; + break; + case GL_SHARED_TEXTURE_PALETTE_EXT: + fxDDTexUseGlbPalette(ctx, state); + break; + case GL_FOG: + fxMesa->new_state |= FX_NEW_FOG; + break; + case GL_CULL_FACE: + fxMesa->new_state |= FX_NEW_CULL; + break; + case GL_LINE_SMOOTH: + case GL_LINE_STIPPLE: + case GL_POINT_SMOOTH: + case GL_POLYGON_SMOOTH: + case GL_TEXTURE_2D: fxMesa->new_state |= FX_NEW_TEXTURING; break; - default: - ; /* XXX no-op? */ - } + default: + ; /* XXX no-op? */ + } } #if 0 @@ -1638,47 +1644,48 @@ void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state) Cc*Ct gets written during the second pass (in this function) Everything gets reset in the third call (in this function) */ -static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass) +static GLboolean +fxMultipassBlend(struct vertex_buffer *VB, GLuint pass) { - GLcontext *ctx = VB->ctx; - fxMesaContext fxMesa = FX_CONTEXT(ctx); - - switch (pass) { - case 1: - /* Add Cc*Ct */ - fxMesa->restoreUnitsState=fxMesa->unitsState; - if (ctx->Depth.Mask) { - /* We don't want to check or change the depth buffers */ - switch (ctx->Depth.Func) { - case GL_NEVER: - case GL_ALWAYS: - break; - default: - fxDDDepthFunc(ctx, GL_EQUAL); - break; + GLcontext *ctx = VB->ctx; + fxMesaContext fxMesa = FX_CONTEXT(ctx); + + switch (pass) { + case 1: + /* Add Cc*Ct */ + fxMesa->restoreUnitsState = fxMesa->unitsState; + if (ctx->Depth.Mask) { + /* We don't want to check or change the depth buffers */ + switch (ctx->Depth.Func) { + case GL_NEVER: + case GL_ALWAYS: + break; + default: + fxDDDepthFunc(ctx, GL_EQUAL); + break; + } + fxDDDepthMask(ctx, FALSE); } - fxDDDepthMask(ctx, FALSE); - } - /* Enable Cc*Ct mode */ - /* XXX Set the Constant Color ? */ - fxDDEnable(ctx, GL_BLEND, GL_TRUE); - fxDDBlendFunc(ctx, XXX, XXX); - fxSetupTextureSingleTMU(ctx, XXX); - fxSetupBlend(ctx); - fxSetupDepthTest(ctx); - break; - - case 2: - /* Reset everything back to normal */ - fxMesa->unitsState = fxMesa->restoreUnitsState; - fxMesa->setup_gone |= XXX; - fxSetupTextureSingleTMU(ctx, XXX); - fxSetupBlend(ctx); - fxSetupDepthTest(ctx); - break; - } - - return pass==1; + /* Enable Cc*Ct mode */ + /* XXX Set the Constant Color ? */ + fxDDEnable(ctx, GL_BLEND, GL_TRUE); + fxDDBlendFunc(ctx, XXX, XXX); + fxSetupTextureSingleTMU(ctx, XXX); + fxSetupBlend(ctx); + fxSetupDepthTest(ctx); + break; + + case 2: + /* Reset everything back to normal */ + fxMesa->unitsState = fxMesa->restoreUnitsState; + fxMesa->setup_gone |= XXX; + fxSetupTextureSingleTMU(ctx, XXX); + fxSetupBlend(ctx); + fxSetupDepthTest(ctx); + break; + } + + return pass == 1; } #endif @@ -1694,7 +1701,8 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass) * voodoo 1. In all other cases for both voodoo 1 and 2, we fall back * to software rendering, satisfying the spec if not the user. */ -static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass ) +static GLboolean +fxMultipassTexture(GLcontext * ctx, GLuint pass) { fxMesaContext fxMesa = FX_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -1703,15 +1711,16 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass ) switch (pass) { case 1: - if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_PIPELINE|VERBOSE_TEXTURE)) - fprintf(stderr, "fxmesa: Second texture pass\n"); + if (MESA_VERBOSE & + (VERBOSE_DRIVER | VERBOSE_PIPELINE | VERBOSE_TEXTURE)) + fprintf(stderr, "fxmesa: Second texture pass\n"); - for ( ; v != last ; v++) { + for (; v != last; v++) { v->f[S0COORD] = v->f[S1COORD]; v->f[T0COORD] = v->f[T1COORD]; } - fxMesa->restoreUnitsState = fxMesa->unitsState; + fxMesa->restoreUnitsState = fxMesa->unitsState; fxMesa->tmu_source[0] = 1; if (ctx->Depth.Mask) { @@ -1720,21 +1729,21 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass ) case GL_ALWAYS: break; default: - fxDDDepthFunc( ctx, GL_EQUAL ); + fxDDDepthFunc(ctx, GL_EQUAL); break; } - fxDDDepthMask( ctx, GL_FALSE ); + fxDDDepthMask(ctx, GL_FALSE); } - + if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) { - fxDDEnable( ctx, GL_BLEND, GL_TRUE ); - fxDDBlendFunc( ctx, GL_DST_COLOR, GL_ZERO ); + fxDDEnable(ctx, GL_BLEND, GL_TRUE); + fxDDBlendFunc(ctx, GL_DST_COLOR, GL_ZERO); } - fxSetupTextureSingleTMU( ctx, 1 ); - fxSetupBlend( ctx ); - fxSetupDepthTest( ctx ); + fxSetupTextureSingleTMU(ctx, 1); + fxSetupBlend(ctx); + fxSetupDepthTest(ctx); break; case 2: @@ -1743,13 +1752,13 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass ) fxMesa->tmu_source[0] = 0; fxMesa->unitsState = fxMesa->restoreUnitsState; fxMesa->setup_gone |= SETUP_TMU0; - fxSetupTextureSingleTMU( ctx, 0 ); - fxSetupBlend( ctx ); - fxSetupDepthTest( ctx ); + fxSetupTextureSingleTMU(ctx, 0); + fxSetupBlend(ctx); + fxSetupDepthTest(ctx); break; } - return pass == 1; + return pass == 1; } @@ -1760,7 +1769,8 @@ static GLboolean fxMultipassTexture( GLcontext *ctx, GLuint pass ) /* All units setup is handled under texture setup. */ -void fxDDShadeModel(GLcontext *ctx, GLenum mode) +void +fxDDShadeModel(GLcontext * ctx, GLenum mode) { FX_CONTEXT(ctx)->new_state |= FX_NEW_TEXTURING; } @@ -1770,59 +1780,61 @@ void fxDDShadeModel(GLcontext *ctx, GLenum mode) /************************************************************************/ /****************************** Units SetUp *****************************/ /************************************************************************/ -static void fx_print_state_flags( const char *msg, GLuint flags ) +static void +fx_print_state_flags(const char *msg, GLuint flags) { - fprintf(stderr, + fprintf(stderr, "%s: (0x%x) %s%s%s%s%s%s%s\n", msg, flags, - (flags & FX_NEW_TEXTURING) ? "texture, " : "", - (flags & FX_NEW_BLEND) ? "blend, " : "", - (flags & FX_NEW_ALPHA) ? "alpha, " : "", - (flags & FX_NEW_FOG) ? "fog, " : "", - (flags & FX_NEW_SCISSOR) ? "scissor, " : "", - (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "", - (flags & FX_NEW_CULL) ? "cull, " : ""); + (flags & FX_NEW_TEXTURING) ? "texture, " : "", + (flags & FX_NEW_BLEND) ? "blend, " : "", + (flags & FX_NEW_ALPHA) ? "alpha, " : "", + (flags & FX_NEW_FOG) ? "fog, " : "", + (flags & FX_NEW_SCISSOR) ? "scissor, " : "", + (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "", + (flags & FX_NEW_CULL) ? "cull, " : ""); } -void fxSetupFXUnits( GLcontext *ctx ) +void +fxSetupFXUnits(GLcontext * ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLuint newstate = fxMesa->new_state; + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; + GLuint newstate = fxMesa->new_state; - if (MESA_VERBOSE&VERBOSE_DRIVER) - fx_print_state_flags("fxmesa: fxSetupFXUnits", newstate); + if (MESA_VERBOSE & VERBOSE_DRIVER) + fx_print_state_flags("fxmesa: fxSetupFXUnits", newstate); - if (newstate) { - if (newstate & FX_NEW_TEXTURING) - fxSetupTexture(ctx); + if (newstate) { + if (newstate & FX_NEW_TEXTURING) + fxSetupTexture(ctx); - if (newstate & FX_NEW_BLEND) - fxSetupBlend(ctx); + if (newstate & FX_NEW_BLEND) + fxSetupBlend(ctx); - if (newstate & FX_NEW_ALPHA) - fxSetupAlphaTest(ctx); - - if (newstate & FX_NEW_DEPTH) - fxSetupDepthTest(ctx); + if (newstate & FX_NEW_ALPHA) + fxSetupAlphaTest(ctx); - if (newstate & FX_NEW_FOG) - fxSetupFog(ctx); + if (newstate & FX_NEW_DEPTH) + fxSetupDepthTest(ctx); - if (newstate & FX_NEW_SCISSOR) - fxSetupScissor(ctx); + if (newstate & FX_NEW_FOG) + fxSetupFog(ctx); - if (newstate & FX_NEW_COLOR_MASK) - fxSetupColorMask(ctx); + if (newstate & FX_NEW_SCISSOR) + fxSetupScissor(ctx); - if (newstate & FX_NEW_CULL) - fxSetupCull(ctx); + if (newstate & FX_NEW_COLOR_MASK) + fxSetupColorMask(ctx); - fxMesa->draw_point = fxMesa->initial_point; - fxMesa->draw_line = fxMesa->initial_line; - fxMesa->draw_tri = fxMesa->initial_tri; - fxMesa->new_state = 0; - } + if (newstate & FX_NEW_CULL) + fxSetupCull(ctx); + + fxMesa->draw_point = fxMesa->initial_point; + fxMesa->draw_line = fxMesa->initial_line; + fxMesa->draw_tri = fxMesa->initial_tri; + fxMesa->new_state = 0; + } } @@ -1835,9 +1847,10 @@ void fxSetupFXUnits( GLcontext *ctx ) */ extern int gl_fx_dummy_function_setup(void); -int gl_fx_dummy_function_setup(void) +int +gl_fx_dummy_function_setup(void) { - return 0; + return 0; } -#endif /* FX */ +#endif /* FX */ |