summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/r300_state.c
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2008-06-30 00:44:26 +0200
committerNicolai Haehnle <nhaehnle@gmail.com>2008-06-30 00:49:00 +0200
commit4002b75e6267ecd0f9e3093e221e34ed5c8485d4 (patch)
treedb290fbec2d9c71d72444e857a5bd0138a48a494 /src/mesa/drivers/dri/r300/r300_state.c
parenta74d22ba715da5e52efb15aebd15a74851f87d43 (diff)
r300: Cleanup LodBias support
. There is both a per-texture unit and a per-texture object (at least for OpenGL 1.4); this should now be supported properly. . The LOD bias calculation in r300_state has been simplified and corrected (need to multiply by 32 instead of 31, and ensure clamping) . do not clamp LOD bias in TexEnv, as that behaviour conflicts with what the spec says . set Const.MaxTextureLodBias properly . remove the no_neg_lod_bias property; if somebody can explain what it's good for, we can add it back in, but according to Google, nobody seems to use it . removed some dead code and unused variables
Diffstat (limited to 'src/mesa/drivers/dri/r300/r300_state.c')
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 00351014af..9e4cc777a9 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1381,16 +1381,14 @@ static void r500SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings)
}
}
-static GLuint r300CalculateTexLodBias(GLfloat bias)
+static GLuint translate_lod_bias(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;
+ GLint b = (int)(bias*32);
+ if (b >= (1 << 9))
+ b = (1 << 9)-1;
+ else if (b < -(1 << 9))
+ b = -(1 << 9);
+ return ((GLuint)b) << R300_LOD_BIAS_SHIFT;
}
static void r300SetupTextures(GLcontext * ctx)
@@ -1456,10 +1454,14 @@ static void r300SetupTextures(GLcontext * ctx)
r300->hw.tex.filter.cmd[R300_TEX_VALUE_0 +
hw_tmu] =
gen_fixed_filter(t->filter) | (hw_tmu << 28);
- /* Make LOD bias a bit more per-tex and less per-everything. */
- t->filter_1 &= ~R300_LOD_BIAS_MASK;
- t->filter_1 |= r300CalculateTexLodBias(ctx->Texture.Unit[i].LodBias);
- r300->hw.tex.filter_1.cmd[R300_TEX_VALUE_0 + hw_tmu] = t->filter_1;
+ /* Note: There is a LOD bias per texture unit and a LOD bias
+ * per texture object. We add them here to get the correct behaviour.
+ * (The per-texture object LOD bias was introduced in OpenGL 1.4
+ * and is not present in the EXT_texture_object extension).
+ */
+ r300->hw.tex.filter_1.cmd[R300_TEX_VALUE_0 + hw_tmu] =
+ t->filter_1 |
+ translate_lod_bias(ctx->Texture.Unit[i].LodBias + t->base.tObj->LodBias);
r300->hw.tex.size.cmd[R300_TEX_VALUE_0 + hw_tmu] =
t->size;
r300->hw.tex.format.cmd[R300_TEX_VALUE_0 +