From 27b7f896d4492021f8b8c35a69c28f5854ab1f90 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 16 Jun 2008 11:37:32 -0700 Subject: [PATCH] r300: Make LOD bias a persistent environment variable. Per airlied's suggestion. --- src/mesa/drivers/dri/r300/r300_state.c | 15 ++++++++++++++- src/mesa/drivers/dri/r300/r300_tex.c | 13 ------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index a86e4bc3444..55d3d55e900 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1381,6 +1381,18 @@ static void r500SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings) } } +static GLuint r300CalculateTexLodBias(GLfloat bias) +{ + GLuint b; + b = (unsigned int)fabsf(ceilf(bias*31)); + if (signbit(bias)) { + b ^= 0x3ff; /* 10 bits */ + } + b <<= 3; + b &= R300_LOD_BIAS_MASK; + return b; +} + static void r300SetupTextures(GLcontext * ctx) { int i, mtu; @@ -1444,7 +1456,8 @@ static void r300SetupTextures(GLcontext * ctx) r300->hw.tex.filter.cmd[R300_TEX_VALUE_0 + hw_tmu] = gen_fixed_filter(t->filter) | (hw_tmu << 28); - r300->hw.tex.filter_1.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->filter_1; + r300->hw.tex.filter_1.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->filter_1 + | r300CalculateTexLodBias(r300->LODBias); r300->hw.tex.size.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->size; r300->hw.tex.format.cmd[R300_TEX_VALUE_0 + diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c index a3d6f90ef6a..5f54bcad9a3 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.c +++ b/src/mesa/drivers/dri/r300/r300_tex.c @@ -284,7 +284,6 @@ static r300TexObjPtr r300AllocTexObj(struct gl_texture_object *texObj) r300SetTexWrap(t, texObj->WrapS, texObj->WrapT, texObj->WrapR); r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter, texObj->MaxAnisotropy); r300SetTexBorderColor(t, texObj->_BorderChan); - r300SetTexLodBias(t, texObj->LodBias); } return t; @@ -1036,18 +1035,6 @@ static void r300TexEnv(GLcontext * ctx, GLenum target, "no_neg_lod_bias") ? 0.0 : -16.0; bias = CLAMP(bias, min, 16.0); - /* This next part feels quite hackish; - * is there a cleaner way? */ - GLenum target = r300TexUnitTarget(&ctx->Texture.Unit[ctx->Texture.CurrentUnit]); - if (target) { - struct gl_texture_object *texObj = - _mesa_select_tex_object(ctx, &ctx->Texture.Unit[ctx->Texture.CurrentUnit], target); - r300TexObjPtr t = (r300TexObjPtr) texObj->DriverData; - texObj->LodBias = bias; - - r300SetTexLodBias(t, texObj->LodBias); - } - rmesa->LODBias = bias; break; -- 2.30.2