📄 tdfx_texstate.c
字号:
fxMesa->TexCombine[1].InvertRGB = FXTRUE; fxMesa->TexCombine[1].InvertAlpha = FXFALSE; } else { fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].InvertRGB = FXFALSE; fxMesa->TexCombine[1].InvertAlpha = FXFALSE; } if (isalpha[TDFX_TMU0]) { fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].InvertRGB = FXFALSE; fxMesa->TexCombine[0].InvertAlpha = FXFALSE; } else { fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].InvertRGB = FXFALSE; fxMesa->TexCombine[0].InvertAlpha = FXFALSE; } fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_LOCAL; fxMesa->ColorCombine.Local = localc; fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; fxMesa->ColorCombine.Invert = FXFALSE; fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_LOCAL; fxMesa->AlphaCombine.Local = locala; fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; fxMesa->AlphaCombine.Invert = FXFALSE; } else if (envMode0 == GL_REPLACE && envMode1 == GL_ADD) { /* Vulpine sky */ GLboolean isalpha[TDFX_NUM_TMU]; isalpha[tmu0] = (baseFormat0 == GL_ALPHA); isalpha[tmu1] = (baseFormat1 == GL_ALPHA); if (isalpha[TDFX_TMU1]) { fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].InvertRGB = FXTRUE; fxMesa->TexCombine[1].InvertAlpha = FXFALSE; } else { fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].InvertRGB = FXFALSE; fxMesa->TexCombine[1].InvertAlpha = FXFALSE; } if (isalpha[TDFX_TMU0]) { fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].InvertRGB = FXFALSE; fxMesa->TexCombine[0].InvertAlpha = FXFALSE; } else { fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL; fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE; fxMesa->TexCombine[0].InvertRGB = FXFALSE; fxMesa->TexCombine[0].InvertAlpha = FXFALSE; } fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; fxMesa->ColorCombine.Local = localc; fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; fxMesa->ColorCombine.Invert = FXFALSE; fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; fxMesa->AlphaCombine.Local = locala; fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; fxMesa->AlphaCombine.Invert = FXFALSE; } else if (envMode1 == GL_REPLACE) { /* Homeworld2 */ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO; fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO; fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[1].InvertRGB = FXFALSE; fxMesa->TexCombine[1].InvertAlpha = FXFALSE; fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL; fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL; fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE; fxMesa->TexCombine[0].InvertRGB = FXFALSE; fxMesa->TexCombine[0].InvertAlpha = FXFALSE; if ((baseFormat0 == GL_RGB) && (baseFormat0 == GL_LUMINANCE)) { fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL; fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE; fxMesa->AlphaCombine.Local = locala; fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE; fxMesa->AlphaCombine.Invert = FXFALSE; } else { fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE; fxMesa->AlphaCombine.Local = locala; fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE; fxMesa->AlphaCombine.Invert = FXFALSE; } if (baseFormat0 == GL_ALPHA) { fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL; fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE; fxMesa->ColorCombine.Local = localc; fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE; fxMesa->ColorCombine.Invert = FXFALSE; } else { fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER; fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE; fxMesa->ColorCombine.Local = localc; fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE; fxMesa->ColorCombine.Invert = FXFALSE; } } else { _mesa_problem(ctx, "%s: Unexpected dual texture mode encountered", __FUNCTION__); return GL_FALSE; } fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV; fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE; fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE; return GL_TRUE;}/* * This function makes sure that the correct mipmap levels are loaded * in the right places in memory and then makes the Glide calls to * setup the texture source pointers. */static voidsetupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj){ struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData; tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj); const GLcontext *ctx = fxMesa->glCtx; /* Make sure we're not loaded incorrectly */ if (ti->isInTM && !shared->umaTexMemory) { /* if doing filtering between mipmap levels, alternate mipmap levels * must be in alternate TMUs. */ if (ti->LODblend) { if (ti->whichTMU != TDFX_TMU_SPLIT) tdfxTMMoveOutTM_NoLock(fxMesa, tObj); } else { if (ti->whichTMU == TDFX_TMU_SPLIT) tdfxTMMoveOutTM_NoLock(fxMesa, tObj); } } /* Make sure we're loaded correctly */ if (!ti->isInTM) { /* Have to download the texture */ if (shared->umaTexMemory) { tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); } else { /* Voodoo3 (split texture memory) */ if (ti->LODblend) { tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU_SPLIT); } else {#if 0 /* XXX putting textures into the second memory bank when the * first bank is full is not working at this time. */ if (fxMesa->haveTwoTMUs) { GLint memReq = fxMesa->Glide.grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH, &(ti->info)); if (shared->freeTexMem[TDFX_TMU0] > memReq) { tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); } else { tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU1); } } else#endif { tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0); } } } } if (ti->LODblend && ti->whichTMU == TDFX_TMU_SPLIT) { /* mipmap levels split between texture banks */ GLint u; if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) { fxMesa->TexPalette.Type = ti->paltype; fxMesa->TexPalette.Data = &(ti->palette); fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE; } for (u = 0; u < 2; u++) { fxMesa->TexParams[u].sClamp = ti->sClamp; fxMesa->TexParams[u].tClamp = ti->tClamp; fxMesa->TexParams[u].minFilt = ti->minFilt; fxMesa->TexParams[u].magFilt = ti->magFilt; fxMesa->TexParams[u].mmMode = ti->mmMode; fxMesa->TexParams[u].LODblend = ti->LODblend; fxMesa->TexParams[u].LodBias = ctx->Texture.Unit[u].LodBias; } fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS; fxMesa->TexSource[0].StartAddress = ti->tm[TDFX_TMU0]->startAddr; fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD; fxMesa->TexSource[0].Info = &(ti->info); fxMesa->TexSource[1].StartAddress = ti->tm[TDFX_TMU1]->startAddr; fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN; fxMesa->TexSource[1].Info = &(ti->info); fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; } else { FxU32 tmu; if (ti->whichTMU == TDFX_TMU_BOTH) tmu = TDFX_TMU0; else tmu = ti->whichTMU; if (shared->umaTexMemory) { assert(ti->whichTMU == TDFX_TMU0); assert(tmu == TDFX_TMU0); } if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) { fxMesa->TexPalette.Type = ti->paltype; fxMesa->TexPalette.Data = &(ti->palette); fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_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 (fxMesa->TexParams[tmu].sClamp != ti->sClamp || fxMesa->TexParams[tmu].tClamp != ti->tClamp || fxMesa->TexParams[tmu].minFilt != ti->minFilt || fxMesa->TexParams[tmu].magFilt != ti->magFilt || fxMesa->TexParams[tmu].mmMode != ti->mmMode || fxMesa->TexParams[tmu].LODblend != FXFALSE || fxMesa->TexParams[tmu].LodBias != ctx->Texture.Unit[tmu].LodBias) { fxMesa->TexParams[tmu].sClamp = ti->sClamp; fxMesa->TexParams[tmu].tClamp = ti->tClamp; fxMesa->TexParams[tmu].minFilt = ti->minFilt; fxMesa->TexParams[tmu].magFilt = ti->magFilt; fxMesa->TexParams[tmu].mmMode = ti->mmMode; fxMesa->TexParams[tmu].LODblend = FXFALSE; fxMesa->TexParams[tmu].LodBias = ctx->Texture.Unit[tmu].LodBias; fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS; } /* Glide texture source info */ fxMesa->TexSource[0].Info = NULL; fxMesa->TexSource[1].Info = NULL; if (ti->tm[tmu]) { fxMesa->TexSource[tmu].StartAddress = ti->tm[tmu]->startAddr; fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH; fxMesa->TexSource[tmu].Info = &(ti->info); fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE; } } fxMesa->sScale0 = ti->sScale; fxMesa->tScale0 = ti->tScale;}static voidselectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend){ if (LODblend) { fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND; fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND; fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION; fxMesa->TexCombine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -