From: Aapo Tahkola Date: Mon, 13 Mar 2006 18:23:19 +0000 (+0000) Subject: Fix broken max mipmap leveling that was horribly wrong. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a0cf4ceb36cf3604fb035276efef4b640ab38c24;p=mesa.git Fix broken max mipmap leveling that was horribly wrong. --- diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index ddf2ab72b94..59d0eda3f48 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -350,7 +350,7 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_GB_LINE_STUFF_ENABLE (1<<1) # define R300_GB_TRIANGLE_STUFF_ENABLE (1<<2) # define R300_GB_STENCIL_AUTO_ENABLE (1<<4) -# define R300_GB_UNK30 (1<<30) +# define R300_GB_UNK31 (1<<31) /* each of the following is 2 bits wide */ #define R300_GB_TEX_REPLICATE 0 #define R300_GB_TEX_ST 1 @@ -552,7 +552,7 @@ I am fairly certain that they are correct unless stated otherwise in comments. #define R300_RS_CNTL_0 0x4300 # define R300_RS_CNTL_TC_CNT_SHIFT 2 # define R300_RS_CNTL_TC_CNT_MASK (7 << 2) -# define R300_RS_CNTL_CI_CNT_SHIFT 7 /* number of color interpolators used */ +# define R300_RS_CNTL_CI_CNT_SHIFT 7 /* number of color interpolators used */ # define R300_RS_CNTL_0_UNKNOWN_18 (1 << 18) /* Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n register. */ #define R300_RS_CNTL_1 0x4304 @@ -739,8 +739,8 @@ I am fairly certain that they are correct unless stated otherwise in comments. # define R300_TX_HEIGHTMASK_SHIFT 11 # define R300_TX_HEIGHTMASK_MASK (2047 << 11) # define R300_TX_UNK23 (1 << 23) -# define R300_TX_SIZE_SHIFT 26 /* largest of width, height */ -# define R300_TX_SIZE_MASK (15 << 26) +# define R300_TX_MAX_MIP_LEVEL_SHIFT 26 +# define R300_TX_MAX_MIP_LEVEL_MASK (0xf << 26) # define R300_TX_SIZE_PROJECTED (1<<30) # define R300_TX_SIZE_TXPITCH_EN (1<<31) #define R300_TX_FORMAT_0 0x44C0 diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 22ec5391e46..575e53c4cb8 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -975,46 +975,6 @@ static void r300PolygonOffset(GLcontext * ctx, GLfloat factor, GLfloat units) /* Routing and texture-related */ -static r300TexObj default_tex_obj={ - filter:R300_TX_MAG_FILTER_LINEAR | R300_TX_MIN_FILTER_LINEAR, - pitch: 0x8000, - size: (0xff << R300_TX_WIDTHMASK_SHIFT) - | (0xff << R300_TX_HEIGHTMASK_SHIFT) - | (0x8 << R300_TX_SIZE_SHIFT), - format: 0x88a0c, - offset: 0x0, - unknown4: 0x0, - unknown5: 0x0 - }; - - /* there is probably a system to these value, but, for now, - we just try by hand */ - -static int inline translate_src(int src) -{ - switch (src) { - case GL_TEXTURE: - return 1; - break; - case GL_CONSTANT: - return 2; - break; - case GL_PRIMARY_COLOR: - return 3; - break; - case GL_PREVIOUS: - return 4; - break; - case GL_ZERO: - return 5; - break; - case GL_ONE: - return 6; - break; - default: - return 0; - } -} /* r300 doesnt handle GL_CLAMP and GL_MIRROR_CLAMP_EXT correctly when filter is NEAREST. * Since texwrap produces same results for GL_CLAMP and GL_CLAMP_TO_EDGE we use them instead. @@ -1124,18 +1084,9 @@ void r300_setup_textures(GLcontext *ctx) tmu_mappings[i] = hw_tmu; t=r300->state.texture.unit[i].texobj; - //fprintf(stderr, "format=%08x\n", r300->state.texture.unit[i].format); - if(t == NULL){ - fprintf(stderr, "Texture unit %d enabled, but corresponding texobj is NULL, using default object.\n", i); - exit(-1); - t=&default_tex_obj; - } - - //fprintf(stderr, "t->format=%08x\n", t->format); if((t->format & 0xffffff00)==0xffffff00) { WARN_ONCE("unknown texture format (entry %x) encountered. Help me !\n", t->format & 0xff); - //fprintf(stderr, "t->format=%08x\n", t->format); } if (RADEON_DEBUG & DEBUG_STATE) @@ -1145,11 +1096,20 @@ void r300_setup_textures(GLcontext *ctx) r300->hw.tex.filter.cmd[R300_TEX_VALUE_0 + hw_tmu] = gen_fixed_filter(t->filter) | (hw_tmu << 28); /* Currently disabled! */ - r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0 + hw_tmu] = 0x0; + r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0 + hw_tmu] = 0x0; //0x20501f80; r300->hw.tex.size.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->size; r300->hw.tex.format.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->format; r300->hw.tex.pitch.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->pitch_reg; r300->hw.tex.offset.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->offset; + + if(t->offset & R300_TXO_MACRO_TILE) { + WARN_ONCE("macro tiling enabled!\n"); + } + + if(t->offset & R300_TXO_MICRO_TILE) { + WARN_ONCE("micro tiling enabled!\n"); + } + r300->hw.tex.unknown4.cmd[R300_TEX_VALUE_0 + hw_tmu] = 0x0; r300->hw.tex.border_color.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->pp_border_color; @@ -1885,7 +1845,7 @@ void r300ResetHwState(r300ContextPtr r300) r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE | R300_GB_LINE_STUFF_ENABLE - | R300_GB_TRIANGLE_STUFF_ENABLE /*| R300_GB_UNK30*/; + | R300_GB_TRIANGLE_STUFF_ENABLE /*| R300_GB_UNK31*/; r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666; r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666; @@ -2048,6 +2008,9 @@ void r300ResetHwState(r300ContextPtr r300) exit(-1); } + /* z compress? */ + //r300->hw.unk4F10.cmd[1] |= R300_DEPTH_FORMAT_UNK32; + r300->hw.unk4F10.cmd[3] = 0x00000003; r300->hw.unk4F10.cmd[4] = 0x00000000; diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index 32f87d2d95e..74220d370ea 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -381,7 +381,8 @@ static void r300SetTexImages(r300ContextPtr rmesa, } t->size = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << R300_TX_WIDTHMASK_SHIFT) - |((tObj->Image[0][t->base.firstLevel]->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)); + |((tObj->Image[0][t->base.firstLevel]->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)) + |((numLevels - 1) << R300_TX_MAX_MIP_LEVEL_SHIFT); /* Only need to round to nearest 32 for textures, but the blitter * requires 64-byte aligned pitches, and we may/may not need the @@ -390,7 +391,6 @@ static void r300SetTexImages(r300ContextPtr rmesa, if (baseImage->IsCompressed) { t->pitch = (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63); - t->size |= ((log2Width>log2Height)?log2Width:log2Height)<Target == GL_TEXTURE_RECTANGLE_NV) { unsigned int align = blitWidth - 1; @@ -400,7 +400,6 @@ static void r300SetTexImages(r300ContextPtr rmesa, t->pitch_reg = (((tObj->Image[0][t->base.firstLevel]->Width) + align) & ~align) - 1; } else { - t->size |= ((log2Width>log2Height)?log2Width:log2Height)<pitch = ((tObj->Image[0][t->base.firstLevel]->Width * texelBytes) + 63) & ~(63);