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 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;

View File

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

View 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;
}