From bab484a59b21fff84579a492d079d46e27d486dd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 20 Jul 2010 08:40:19 -0600 Subject: mesa: call ctx->Driver.ChooseTextureFormat() only when necessary. When defining mipmap level 'L' and level L-1 exists and the new level's internalFormat matches level L-1's internalFormat, then use the same hw format. Otherwise, do the regular ctx->Driver.ChooseTextureFormat() call. This avoids a problem where we end up choosing different hw formats for different mipmap levels depending on how the levels are defined (glTexImage vs. glCopyTexImage vs. glGenerateMipmap, etc). The root problem is the ChooseTextureFormat() implementation in some drivers uses the user's glTexImage format/type parameters in the choosing heuristic. Later mipmap levels might be generated with different calls (ex: glCopyTexImage()) so we don't always have format/type info and the driver may choose a different format. For more background info see the July 2010 mesa-dev thread "Bug in _mesa_meta_GenerateMipmap" --- src/mesa/drivers/common/meta.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/mesa/drivers/common') diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index c548e10420..dc6e7120c6 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -2570,12 +2570,6 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, return; } - if (texImage->TexFormat == MESA_FORMAT_NONE) - texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, - internalFormat, - format, - type); - _mesa_unlock_texture(ctx, texObj); /* need to unlock first */ /* @@ -2604,6 +2598,9 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, postConvWidth, postConvHeight, 1, border, internalFormat); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); + /* * Store texture data (with pixel transfer ops) */ -- cgit v1.2.3