From d7d54423a850aeefb07c131a9cc3dbbd5244468c Mon Sep 17 00:00:00 2001 From: Vladimir Dergachev Date: Mon, 24 Jan 2005 17:09:17 +0000 Subject: [PATCH] Remove lots of old code that dealed with "magic" texture formats. --- src/mesa/drivers/dri/r300/r300_state.c | 209 --------------------------------- 1 file changed, 209 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index b2b5939..aeeec96 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1004,150 +1004,6 @@ static int inline translate_src(int src) } } -/* I think 357 and 457 are prime numbers.. wiggle them if you get coincidences */ -#define FORMAT_HASH(opRGB, srcRGB, modeRGB, opA, srcA, modeA, format, intFormat) ( \ - (\ - ((opRGB)<<30) | ((opA)<<28) | \ - ((srcRGB)<< 25) | ((srcA)<<22) | \ - ((modeRGB)) \ - ) \ - ^ ((modeA)*357) \ - ^ (((format)) *457) \ - ^ ((intFormat) * 7) \ - ) - - -static GLuint translate_texture_format(GLcontext *ctx, GLint tex_unit, GLuint format, GLint IntFormat, - struct gl_texture_format *tex_format) -{ - const struct gl_texture_unit *texUnit= &ctx->Texture.Unit[tex_unit]; - int i=0; /* number of alpha args .. */ - GLuint fmt; - - #if 0 - fprintf(stderr, "_ReallyEnabled=%d EnvMode=%s\n", - texUnit->_ReallyEnabled, - _mesa_lookup_enum_by_nr(texUnit->EnvMode)); - #endif - - if(tex_format==NULL){ - fprintf(stderr, "Aeiii ! tex_format==NULL !!\n"); - return 0; - } - - switch(tex_format->MesaFormat){ - case MESA_FORMAT_RGBA8888: - return R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8); - default: - fprintf(stderr, "Do not know format %s\n", _mesa_lookup_enum_by_nr(tex_format->MesaFormat)); - return 0; - } - - switch(IntFormat){ - case 4: - case GL_RGBA: - case GL_RGBA8: - break; - case 3: - case GL_RGB8: - fmt=R300_EASY_TX_FORMAT(Y, Z, W, ONE, W8Z8Y8X8); - break; - default: - return 0; - } - #if 1 - //fmt &= 0x00fff; - //fmt |= ((format) & 0xff00)<<4; - fprintf(stderr, "NumArgsRGB=%d NumArgsA=%d\n", - texUnit->_CurrentCombine->_NumArgsRGB, - texUnit->_CurrentCombine->_NumArgsA); - - fprintf(stderr, "fmt=%08x\n", fmt); - #endif - return fmt; - /* Size field in format specific first */ - switch(FORMAT_HASH( - texUnit->_CurrentCombine->OperandRGB[i] -GL_SRC_COLOR, - translate_src(texUnit->_CurrentCombine->SourceRGB[i]), - texUnit->_CurrentCombine->ModeRGB, - texUnit->_CurrentCombine->OperandA[i] -GL_SRC_ALPHA, - translate_src(texUnit->_CurrentCombine->SourceA[i]), - texUnit->_CurrentCombine->ModeA, - format, - IntFormat - )){ - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x0008847, GL_RGBA): - /* tested with: - kfiresaver.kss - */ - return R300_EASY_TX_FORMAT(X, X, CUT_W, W, W8Z8Y8X8); - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x0008847, GL_RGBA8): - /* tested with: - Quake3demo - */ - /* Quake3demo -small font on the bottom */ - return fmt; - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x00005547, GL_RGBA8): - /* Quake3demo - mouse cursor*/ - return fmt; - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x00007747, 4): - /* tested with: - kfiresaver.kss - */ - return R300_EASY_TX_FORMAT(Y, Z, W, ONE, W8Z8Y8X8); - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x00005547, 4): - /* tested with: - kfiresaver.kss - kfountain.kss - */ - return R300_EASY_TX_FORMAT(Y, Z, W, ONE, W8Z8Y8X8); - case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x00008847, 3): - /* tested with - lesson 06 - lesson 07 - */ - case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x00007747, 0x00000003): - /* Tested with NeHe lesson 08 */ - //case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x0005547, 0): - /* Can't remember what I tested this with.. - try putting return 0 of you see broken textures which - are not being complained about */ - case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x00009947, GL_RGB8): - case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x00007747, GL_RGB8): - case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x00003347, GL_RGB8): - case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x00008947, 3): - /* Tested with: - Quake3demo - */ - return R300_EASY_TX_FORMAT(Y, Z, W, ONE, W8Z8Y8X8); - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x00007847, GL_RGBA8): - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x00006747, GL_RGBA8): - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x00006647, GL_RGBA8): - case FORMAT_HASH(0, 1, 0x2100, 0, 4, 0x1e01, 0x00008947, GL_RGBA8): - /* Tested with: - Quake3demo - */ - return R300_EASY_TX_FORMAT(Y, Z, W, W, W8Z8Y8X8); - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x00007747, GL_RGBA8): - return R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8) ; - case FORMAT_HASH(0, 1, 0x2100, 0, 1, 0x2100, 0x0008845, 0x00008056): - //return 0; - fprintf(stderr, "***\n"); - return R300_EASY_TX_FORMAT(Y, Z, W, W, W8Z8Y8X8); - } - - - { - static int warn_once=1; - if(warn_once){ - fprintf(stderr, "%s:%s Do not know how to translate texture format - help me !\n", - __FILE__, __FUNCTION__); - warn_once=0; - } - } - return 0; -} - void r300_setup_textures(GLcontext *ctx) { int i, mtu; @@ -1205,71 +1061,6 @@ void r300_setup_textures(GLcontext *ctx) r300->hw.tex.unknown4.cmd[R300_TEX_VALUE_0+i]=0x0; r300->hw.tex.unknown5.cmd[R300_TEX_VALUE_0+i]=0x0; r300->hw.tex.border_color.cmd[R300_TEX_VALUE_0+i]=t->pp_border_color; - - /* We don't know how to set this yet */ - //value from r300_lib.c for RGB24 - //r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=0x88a0c; - #if 0 - r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=translate_texture_format(ctx, i, t->format, - r300->state.texture.unit[i].texobj!=NULL?t->base.tObj->Image[0][0]->IntFormat:3, - r300->state.texture.unit[i].texobj!=NULL?t->base.tObj->Image[0][0]->TexFormat:NULL); - #endif - - #if 0 - fprintf(stderr, "Format=%s IntFormat=%08x MesaFormat=%08x BaseFormat=%s IsCompressed=%d Target=%s\n", - _mesa_lookup_enum_by_nr(t->base.tObj->Image[0][0]->Format), - t->base.tObj->Image[0][0]->IntFormat, - t->base.tObj->Image[0][0]->TexFormat->MesaFormat, - _mesa_lookup_enum_by_nr(t->base.tObj->Image[0][0]->TexFormat->BaseFormat), - t->base.tObj->Image[0][0]->IsCompressed, - _mesa_lookup_enum_by_nr(t->base.tObj->Target)); - - fprintf(stderr, "pitch=%08x filter=%08x format=%08x\n", t->pitch, t->filter, r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]); - fprintf(stderr, "unknown1=%08x size=%08x\n", r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+i], - r300->hw.tex.size.cmd[R300_TEX_VALUE_0+i]); - #endif - /* Use the code below to quickly find matching texture - formats. Requires an app that displays the same texture - repeatedly */ - #if 0 - if(r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]==0){ - static int fmt=0x0; - static int k=0; - k++; - if(k>20){ - k=0; - fmt++; - texUnit = &ctx->Texture.Unit[i]; - fprintf(stderr, "Want to set FORMAT_HASH(%d, %d, 0x%04x, %d, %d, 0x%04x, 0x%08x, %s(%08x))\n", - texUnit->_CurrentCombine->OperandRGB[0] -GL_SRC_COLOR, - translate_src(texUnit->_CurrentCombine->SourceRGB[0]), - texUnit->_CurrentCombine->ModeRGB, - texUnit->_CurrentCombine->OperandA[0] -GL_SRC_ALPHA, - translate_src(texUnit->_CurrentCombine->SourceA[0]), - texUnit->_CurrentCombine->ModeA, - t->format, - _mesa_lookup_enum_by_nr(t->base.tObj->Image[0][0]->IntFormat), - t->base.tObj->Image[0][0]->IntFormat - ); - fprintf(stderr, "Also known: format_x=%08x border_color=%08x cubic_faces=%08x\n", t->format_x, t->pp_border_color, t->pp_cubic_faces); - fprintf(stderr, "\t_ReallyEnabled=%08x EnvMode=%08x IntFormat=%08x\n", texUnit->_ReallyEnabled, texUnit->EnvMode, t->base.tObj->Image[0][0]->IntFormat); - if(fmt>0xfff){ - fmt=0; - } - //sleep(1); - fprintf(stderr, "Now trying format %08x\n", - fmt); - fprintf(stderr, "size=%08x\n", t->size); - } - //r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=known_formats[fmt]; - r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]= - R300_EASY_TX_FORMAT(Z, Y, X, W, W8Z8Y8X8) | (fmt<<24); - //r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=0x08a0c | (fmt<<16); - //r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=0x58a00 | (fmt); - //r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=0x53a0c | (fmt<<24); - } - #endif - } } -- 2.7.4