r300: Fix new incarnation of bug 3195.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 16 Jun 2008 08:21:42 +0000 (01:21 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 16 Jun 2008 08:21:42 +0000 (01:21 -0700)
tests/bug_3195 doesn't render right, but at least it doesn't segfault this way.

progs/demos/lodbias.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_tex.c

index c5a2a1b457315f99530692e4d1781d781ae4df47..28215d46c07217e62ef3fad228fca12df887a349 100644 (file)
@@ -40,7 +40,7 @@
 
 static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
 static GLboolean Anim = GL_TRUE;
-static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
+static GLint Bias = 4, BiasStepSign = +1; /* ints avoid fp precision problem */
 static GLint BiasMin = -400, BiasMax = 400;
 
 
index 1a90f5cabb2fb6174acd9abc5886aa852a906521..6279a67ab1628f35a5028f19aa0c592b33d79272 100644 (file)
@@ -925,6 +925,7 @@ struct r300_context {
        driTextureObject swapped;
        int texture_depth;
        float initialMaxAnisotropy;
+       float LODBias;
 
        /* Clientdata textures;
         */
index b672baca1b627c0fdf9cdd1a09575cdcd385d0e4..a3d6f90ef6aea1482aa86e3e67270026e069f087 100644 (file)
@@ -1005,6 +1005,7 @@ static GLenum r300TexUnitTarget(struct gl_texture_unit *unit) {
        } else if (unit->Enabled & (TEXTURE_CUBE_BIT)) {
                return GL_TEXTURE_CUBE_MAP;
        }
+       return 0;
 }
 
 static void r300TexEnv(GLcontext * ctx, GLenum target,
@@ -1037,13 +1038,17 @@ static void r300TexEnv(GLcontext * ctx, GLenum target,
 
                /* This next part feels quite hackish;
                 * is there a cleaner way? */
-               struct gl_texture_object *texObj;
                GLenum target = r300TexUnitTarget(&ctx->Texture.Unit[ctx->Texture.CurrentUnit]);
-               texObj = _mesa_select_tex_object(ctx, &ctx->Texture.Unit[ctx->Texture.CurrentUnit], target);
-               r300TexObjPtr t = (r300TexObjPtr) texObj->DriverData;
-               texObj->LodBias = bias;
+               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);
+                       r300SetTexLodBias(t, texObj->LodBias);
+               }
+
+               rmesa->LODBias = bias;
 
                break;
        }
@@ -1175,6 +1180,10 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
                return NULL;
        obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
 
+       /* Attempt to fill LOD bias, if previously set.
+        * Should start at 0.0, which won't affect the HW. */
+       obj->LodBias = rmesa->LODBias;
+
        r300AllocTexObj(obj);
        return obj;
 }