r300: Fix new incarnation of bug 3195.

tests/bug_3195 doesn't render right, but at least it doesn't segfault this way.
This commit is contained in:
Corbin Simpson
2008-06-16 01:21:42 -07:00
parent 1738a9a535
commit 588abd6696
3 changed files with 16 additions and 6 deletions

View File

@@ -40,7 +40,7 @@
static GLfloat Xrot = 0, Yrot = -30, Zrot = 0; static GLfloat Xrot = 0, Yrot = -30, Zrot = 0;
static GLboolean Anim = GL_TRUE; 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; static GLint BiasMin = -400, BiasMax = 400;

View File

@@ -925,6 +925,7 @@ struct r300_context {
driTextureObject swapped; driTextureObject swapped;
int texture_depth; int texture_depth;
float initialMaxAnisotropy; float initialMaxAnisotropy;
float LODBias;
/* Clientdata textures; /* Clientdata textures;
*/ */

View File

@@ -1005,6 +1005,7 @@ static GLenum r300TexUnitTarget(struct gl_texture_unit *unit) {
} else if (unit->Enabled & (TEXTURE_CUBE_BIT)) { } else if (unit->Enabled & (TEXTURE_CUBE_BIT)) {
return GL_TEXTURE_CUBE_MAP; return GL_TEXTURE_CUBE_MAP;
} }
return 0;
} }
static void r300TexEnv(GLcontext * ctx, GLenum target, static void r300TexEnv(GLcontext * ctx, GLenum target,
@@ -1037,13 +1038,17 @@ static void r300TexEnv(GLcontext * ctx, GLenum target,
/* This next part feels quite hackish; /* This next part feels quite hackish;
* is there a cleaner way? */ * is there a cleaner way? */
struct gl_texture_object *texObj;
GLenum target = r300TexUnitTarget(&ctx->Texture.Unit[ctx->Texture.CurrentUnit]); GLenum target = r300TexUnitTarget(&ctx->Texture.Unit[ctx->Texture.CurrentUnit]);
texObj = _mesa_select_tex_object(ctx, &ctx->Texture.Unit[ctx->Texture.CurrentUnit], target); if (target) {
r300TexObjPtr t = (r300TexObjPtr) texObj->DriverData; struct gl_texture_object *texObj =
texObj->LodBias = bias; _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; break;
} }
@@ -1175,6 +1180,10 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
return NULL; return NULL;
obj->MaxAnisotropy = rmesa->initialMaxAnisotropy; 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); r300AllocTexObj(obj);
return obj; return obj;
} }