summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2008-06-16 11:37:32 -0700
committerCorbin Simpson <MostAwesomeDude@gmail.com>2008-06-16 11:40:34 -0700
commit27b7f896d4492021f8b8c35a69c28f5854ab1f90 (patch)
treeda0899d5dca751aefe1d049a08cf44534b033fd5
parente9d1889891ce32ffb3d6425f1e70510ea2c3e24b (diff)
r300: Make LOD bias a persistent environment variable.
Per airlied's suggestion.
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c15
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.c13
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 a86e4bc344..55d3d55e90 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 a3d6f90ef6..5f54bcad9a 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;