From 588abd66966a672a93e87cd577802255193bebcd Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 16 Jun 2008 01:21:42 -0700 Subject: [PATCH] r300: Fix new incarnation of bug 3195. tests/bug_3195 doesn't render right, but at least it doesn't segfault this way. --- progs/demos/lodbias.c | 2 +- src/mesa/drivers/dri/r300/r300_context.h | 1 + src/mesa/drivers/dri/r300/r300_tex.c | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/progs/demos/lodbias.c b/progs/demos/lodbias.c index c5a2a1b4573..28215d46c07 100644 --- a/progs/demos/lodbias.c +++ b/progs/demos/lodbias.c @@ -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; diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 1a90f5cabb2..6279a67ab16 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -925,6 +925,7 @@ struct r300_context { driTextureObject swapped; int texture_depth; float initialMaxAnisotropy; + float LODBias; /* Clientdata textures; */ diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c index b672baca1b6..a3d6f90ef6a 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.c +++ b/src/mesa/drivers/dri/r300/r300_tex.c @@ -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; } -- 2.30.2