[Mesa-dev] [PATCH] meta: Don't modify GL_GENERATE_MIPMAP state when it doesn't exist

Kenneth Graunke kenneth at whitecape.org
Thu Aug 23 10:16:22 PDT 2012


On 08/22/2012 06:58 PM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> This is a bit of a hack.  _mesa_meta_GenerateMipmap shouldn't even be
> used in contexts where GL_GENERATE_MIPMAP doesn't exist (i.e., core
> profile and ES2) because it uses fixed-function, and fixed-function
> doesn't exist there either!
> 
> A GLSL-based _mesa_meta_GenerateMipmap should be available soon.
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> ---
> Without this patch, the in-reply-to patch breaks glGenerateMipmaps in
> OpenGL ES 2.0 contexts.  With a Reviewed-by, I'll commit this patch
> before the other 18 patch series.
> 
>  src/mesa/drivers/common/meta.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index db49d90..5d219c7 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -3010,7 +3010,10 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
>  
>     _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, mipmap->FBO);
>  
> -   _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
> +   if (ctx->API != API_OPENGLES2 && ctx->API != API_OPENGL_CORE)
> +      _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
> +   else
> +      assert(!genMipmapSave);
>  
>     if (ctx->Extensions.EXT_framebuffer_sRGB) {
>        _mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE);
> @@ -3149,7 +3152,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
>     _mesa_meta_end(ctx);
>  
>     _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, maxLevelSave);
> -   _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, genMipmapSave);
> +   if (genMipmapSave)
> +      _mesa_TexParameteri(target, GL_GENERATE_MIPMAP, genMipmapSave);
>  
>     _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave);
>  }

Ultimately, since this is a fixed-function implementation, we don't want
to have checks for shader-based APIs, since shader-based APIs can't use
this.

That said, this keeps it working as well as it used to, so we should:
1) apply this patch
2) add the GLSL-based implementation
3) use the FF version for ES1 and non-GLSL capable HW, otherwise use the
GLSL one
4) revert this patch

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list