⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fxsetup.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 5 页
字号:
       */      if (ti->LODblend && (TDFX_DEBUG & VERBOSE_DRIVER)) {	 fprintf(stderr, "fxSetupSingleTMU_NoLock: not blending texture - only one tmu\n");      }      grTexClampMode(tmu, ti->sClamp, ti->tClamp);      grTexFilterMode(tmu, ti->minFilt, ti->maxFilt);      grTexMipMapMode(tmu, ti->mmMode, FXFALSE);      grTexSource(tmu, ti->tm[tmu]->startAddr, GR_MIPMAPLEVELMASK_BOTH, &(ti->info));   }}static voidfxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend){   struct tdfx_texcombine tex0, tex1;   if (TDFX_DEBUG & VERBOSE_DRIVER) {      fprintf(stderr, "fxSelectSingleTMUSrc_NoLock(%d, %d)\n", tmu, LODblend);   }   tex0.InvertRGB     = FXFALSE;   tex0.InvertAlpha   = FXFALSE;   tex1.InvertRGB     = FXFALSE;   tex1.InvertAlpha   = FXFALSE;   if (LODblend) {      tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND;      tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION;      tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND;      tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION;      tex1.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;      tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;      tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;      tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;      fxMesa->tmuSrc = FX_TMU_SPLIT;   }   else {      if (tmu != FX_TMU1) {         tex0.FunctionRGB   = GR_COMBINE_FUNCTION_LOCAL;         tex0.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex0.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;         tex0.FactorAlpha   = GR_COMBINE_FACTOR_NONE;         tex1.FunctionRGB   = GR_COMBINE_FUNCTION_ZERO;         tex1.FactorRGB     = GR_COMBINE_FACTOR_NONE;         tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;         tex1.FactorAlpha   = GR_COMBINE_FACTOR_NONE;	 fxMesa->tmuSrc = FX_TMU0;      }      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;	 /* correct values to set TMU0 in passthrough mode */         tex0.FunctionRGB   = GR_COMBINE_FUNCTION_BLEND;         tex0.FactorRGB     = GR_COMBINE_FACTOR_ONE;         tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND;         tex0.FactorAlpha   = GR_COMBINE_FACTOR_ONE;	 fxMesa->tmuSrc = FX_TMU1;      }   }   grTexCombine(GR_TMU0,                tex0.FunctionRGB,                tex0.FactorRGB,                tex0.FunctionAlpha,                tex0.FactorAlpha,                tex0.InvertRGB,                tex0.InvertAlpha);   if (fxMesa->haveTwoTMUs) {      grTexCombine(GR_TMU1,                   tex1.FunctionRGB,                   tex1.FactorRGB,                   tex1.FunctionAlpha,                   tex1.FactorAlpha,                   tex1.InvertRGB,                   tex1.InvertAlpha);   }}static voidfxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset){   fxMesaContext fxMesa = FX_CONTEXT(ctx);   struct tdfx_combine alphaComb, colorComb;   GrCombineLocal_t localc, locala;   GLuint unitsmode;   GLint ifmt;   tfxTexInfo *ti;   struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current;   int tmu;   if (TDFX_DEBUG & VERBOSE_DRIVER) {      fprintf(stderr, "fxSetupTextureSingleTMU_NoLock(%d)\n", textureset);   }   ti = fxTMGetTexInfo(tObj);   fxTexValidate(ctx, 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 (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 (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))      fprintf(stderr, "fxSetupTextureSingleTMU_NoLock: envmode is %s\n",	      _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));   alphaComb.Local    = locala;   alphaComb.Invert   = FXFALSE;   colorComb.Local    = localc;   colorComb.Invert   = FXFALSE;   switch (ctx->Texture.Unit[textureset].EnvMode) {   case GL_DECAL:      alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;      alphaComb.Factor   = GR_COMBINE_FACTOR_NONE;      alphaComb.Other    = GR_COMBINE_OTHER_NONE;      colorComb.Function = GR_COMBINE_FUNCTION_BLEND;      colorComb.Factor   = GR_COMBINE_FACTOR_TEXTURE_ALPHA;      colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;      break;   case GL_MODULATE:      alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;      alphaComb.Factor   = GR_COMBINE_FACTOR_LOCAL;      alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;      if (ifmt == GL_ALPHA) {         colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;         colorComb.Factor   = GR_COMBINE_FACTOR_NONE;         colorComb.Other    = GR_COMBINE_OTHER_NONE;      } else {         colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         colorComb.Factor   = GR_COMBINE_FACTOR_LOCAL;         colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;      }      break;   case GL_BLEND:      if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {         /* Av = Af */         alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;         alphaComb.Factor   = GR_COMBINE_FACTOR_NONE;         alphaComb.Other    = GR_COMBINE_OTHER_NONE;      }      else if (ifmt == GL_INTENSITY) {         /* Av = Af * (1 - It) + Ac * It */         alphaComb.Function = GR_COMBINE_FUNCTION_BLEND;         alphaComb.Factor   = GR_COMBINE_FACTOR_TEXTURE_ALPHA;         alphaComb.Other    = GR_COMBINE_OTHER_CONSTANT;      }      else {         /* Av = Af * At */         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         alphaComb.Factor   = GR_COMBINE_FACTOR_LOCAL;         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;      }      if (ifmt == GL_ALPHA) {         colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;         colorComb.Factor   = GR_COMBINE_FACTOR_NONE;         colorComb.Other    = GR_COMBINE_OTHER_NONE;      } else {         if (fxMesa->type >= GR_SSTTYPE_Voodoo2) {            colorComb.Function = GR_COMBINE_FUNCTION_BLEND;            colorComb.Factor   = GR_COMBINE_FACTOR_TEXTURE_RGB;            colorComb.Other    = GR_COMBINE_OTHER_CONSTANT;         } else if (ifmt == GL_INTENSITY) {            /* just a hack: RGB == ALPHA */            colorComb.Function = GR_COMBINE_FUNCTION_BLEND;            colorComb.Factor   = GR_COMBINE_FACTOR_TEXTURE_ALPHA;            colorComb.Other    = GR_COMBINE_OTHER_CONSTANT;         } else {            /* Only Voodoo^2 can GL_BLEND (GR_COMBINE_FACTOR_TEXTURE_RGB)             * These settings assume that the TexEnv color is black and             * incoming fragment color is white.             */            colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;            colorComb.Factor   = GR_COMBINE_FACTOR_ONE;            colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;            colorComb.Invert   = FXTRUE;            _mesa_problem(NULL, "can't GL_BLEND with SST1");         }      }      grConstantColorValue(         (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[0] * 255.0f))      ) |         (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[1] * 255.0f)) <<  8) |         (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[2] * 255.0f)) << 16) |         (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[3] * 255.0f)) << 24));      break;   case GL_REPLACE:      if ((ifmt == GL_RGB) || (ifmt == GL_LUMINANCE)) {         alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;         alphaComb.Factor   = GR_COMBINE_FACTOR_NONE;         alphaComb.Other    = GR_COMBINE_OTHER_NONE;      } else {         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         alphaComb.Factor   = GR_COMBINE_FACTOR_ONE;         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;      }      if (ifmt == GL_ALPHA) {         colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;         colorComb.Factor   = GR_COMBINE_FACTOR_NONE;         colorComb.Other    = GR_COMBINE_OTHER_NONE;      } else {         colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         colorComb.Factor   = GR_COMBINE_FACTOR_ONE;         colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;      }      break;   case GL_ADD:      if (ifmt == GL_ALPHA ||          ifmt == GL_LUMINANCE_ALPHA ||          ifmt == GL_RGBA) {         /* product of texel and fragment alpha */         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;         alphaComb.Factor   = GR_COMBINE_FACTOR_LOCAL;         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;      }      else if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {         /* fragment alpha is unchanged */         alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;         alphaComb.Factor   = GR_COMBINE_FACTOR_NONE;         alphaComb.Other    = GR_COMBINE_OTHER_NONE;      }      else {         /* sum of texel and fragment alpha */         alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;         alphaComb.Factor   = GR_COMBINE_FACTOR_ONE;         alphaComb.Other    = GR_COMBINE_OTHER_TEXTURE;      }      if (ifmt == GL_ALPHA) {         /* rgb unchanged */         colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;         colorComb.Factor   = GR_COMBINE_FACTOR_NONE;         colorComb.Other    = GR_COMBINE_OTHER_NONE;      }      else {         /* sum of texel and fragment rgb */         colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;         colorComb.Factor   = GR_COMBINE_FACTOR_ONE;         colorComb.Other    = GR_COMBINE_OTHER_TEXTURE;      }      break;   default:      if (TDFX_DEBUG & VERBOSE_DRIVER) {	 fprintf(stderr, "fxSetupTextureSingleTMU_NoLock: %x Texture.EnvMode not yet supported\n",		 ctx->Texture.Unit[textureset].EnvMode);      }      return;   }   grAlphaCombine(alphaComb.Function,                  alphaComb.Factor,                  alphaComb.Local,                  alphaComb.Other,                  alphaComb.Invert);   grColorCombine(colorComb.Function,                  colorComb.Factor,                  colorComb.Local,                  colorComb.Other,                  colorComb.Invert);}#if 00static voidfxSetupTextureSingleTMU(GLcontext * ctx, GLuint textureset){   BEGIN_BOARD_LOCK();   fxSetupTextureSingleTMU_NoLock(ctx, textureset);   END_BOARD_LOCK();}#endif/************************* Double Texture Set ***************************/static voidfxSetupDoubleTMU_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#define T0_IN_TMU0     0x04#define T1_IN_TMU0     0x08#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 (TDFX_DEBUG & VERBOSE_DRIVER) {      fprintf(stderr, "fxSetupDoubleTMU_NoLock(...)\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);	    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -