}
}
+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;
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 +
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;
"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;