summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300
diff options
context:
space:
mode:
authorCorbin Simpson <MostAwesomeDude@gmail.com>2008-06-15 17:14:07 -0700
committerCorbin Simpson <MostAwesomeDude@gmail.com>2008-06-15 17:14:07 -0700
commit6e6ca40f29551b6f6cedea954874930e6470b0b9 (patch)
tree644d85e7762adc5e3111d3ed493d7d4fec0097c1 /src/mesa/drivers/dri/r300
parent4fc66be2964efb0fbce101264b898636f8f1c715 (diff)
r300: Unbreak LOD biasing, a bit.
Needs a bit more work on submission.
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r--src/mesa/drivers/dri/r300/r300_tex.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c
index 16321af7d4..4a989fcde9 100644
--- a/src/mesa/drivers/dri/r300/r300_tex.c
+++ b/src/mesa/drivers/dri/r300/r300_tex.c
@@ -968,6 +968,7 @@ r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
static void r300TexEnv(GLcontext * ctx, GLenum target,
GLenum pname, const GLfloat * param)
{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
if (RADEON_DEBUG & DEBUG_STATE) {
fprintf(stderr, "%s( %s )\n",
__FUNCTION__, _mesa_lookup_enum_by_nr(pname));
@@ -978,41 +979,39 @@ static void r300TexEnv(GLcontext * ctx, GLenum target,
* between them according to _ReallyEnabled.
*/
switch (pname) {
- case GL_TEXTURE_LOD_BIAS_EXT:{
-#if 0 /* Needs to be relocated in order to make sure we got the right tmu */
- GLfloat bias, min;
- GLuint b;
-
- /* The R300's LOD bias is a signed 2's complement value with a
- * range of -16.0 <= bias < 16.0.
- *
- * NOTE: Add a small bias to the bias for conform mipsel.c test.
- */
- bias = *param + .01;
- min =
- driQueryOptionb(&rmesa->radeon.optionCache,
- "no_neg_lod_bias") ? 0.0 : -16.0;
- bias = CLAMP(bias, min, 16.0);
-
- /* 0.0 - 16.0 == 0x0 - 0x1000 */
- /* 0.0 - -16.0 == 0x1001 - 0x1fff */
- b = 0x1000 / 16.0 * bias;
- b &= R300_LOD_BIAS_MASK;
-
- if (b !=
- (rmesa->hw.tex.unknown1.
- cmd[R300_TEX_VALUE_0 +
- unit] & R300_LOD_BIAS_MASK)) {
- R300_STATECHANGE(rmesa, tex.unknown1);
- rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0 +
- unit] &=
- ~R300_LOD_BIAS_MASK;
- rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0 +
- unit] |= b;
- }
-#endif
- break;
+ case GL_TEXTURE_LOD_BIAS_EXT: {
+ fprintf(stderr, "LOD Bias: %f\n", *param);
+ /* Needs to be relocated in order to make sure we got the right tmu */
+ GLfloat bias, min;
+ GLuint b;
+
+ /* The R300's LOD bias is a signed 2's complement value with a
+ * range of -16.0 <= bias < 16.0.
+ *
+ * NOTE: Add a small bias to the bias for conform mipsel.c test.
+ */
+ bias = *param + .01;
+ min = driQueryOptionb(&rmesa->radeon.optionCache,
+ "no_neg_lod_bias") ? 0.0 : -16.0;
+ bias = CLAMP(bias, min, 16.0);
+
+ b = (unsigned int)fabsf(ceilf(bias*31));
+ if (signbit(bias)) {
+ b ^= 0x3ff; /* 10 bits */
}
+ fprintf(stderr, "LOD Bias (hex): 0x%x\n", b);
+ b <<= 3;
+ b &= R300_LOD_BIAS_MASK;
+
+ int unit = 1;
+
+ if (b != (rmesa->hw.tex.filter_1.cmd[R300_TEX_CMD_0 + unit] & R300_LOD_BIAS_MASK)) {
+ R300_STATECHANGE(rmesa, tex.filter_1);
+ rmesa->hw.tex.filter_1.cmd[R300_TEX_CMD_0 + unit] &= ~R300_LOD_BIAS_MASK;
+ rmesa->hw.tex.filter_1.cmd[R300_TEX_CMD_0 + unit] |= b;
+ }
+ break;
+ }
default:
return;