[Mesa-dev] [PATCH] mesa: Allow texture with zero width/height to create miptree

Brian Paul brianp at vmware.com
Mon Jan 16 14:27:52 PST 2012


On 01/16/2012 12:51 PM, Anuj Phogat wrote:
> TestMipMaps() function in src/OGLconform/textureNPOT.c calls glTexImage2D()
> with width = 0. Texture with zero image width skips miptree allocation due to
> a condition in function _mesa_store_teximage3d(). While calling glGetTexImage()
> it results in assertion failure in intel_map_texture_image() due to null mt
> pointer
>
> https://bugs.freedesktop.org/show_bug.cgi?id=42334
>
> Signed-off-by: Anuj Phogat<anuj.phogat at gmail.com>
> ---
>   src/mesa/main/texstore.c |    3 ---
>   1 files changed, 0 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
> index a9c64ce..956276e 100644
> --- a/src/mesa/main/texstore.c
> +++ b/src/mesa/main/texstore.c
> @@ -4601,9 +4601,6 @@ _mesa_store_teximage3d(struct gl_context *ctx,
>                          GLenum format, GLenum type, const void *pixels,
>                          const struct gl_pixelstore_attrib *packing)
>   {
> -   if (width == 0 || height == 0 || depth == 0)
> -      return;
> -
>      /* allocate storage for texture data */
>      if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
>                                               width, height, depth)) {

Note that the _mesa_store_teximage1d and 2d() functions also have 
checks like this.

How about checking for a zero-sized texture image in glGetTexImage() 
instead?

--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -740,8 +740,11 @@ getteximage_error_check(struct gl_context *ctx, 
GLenum targ
     }

     texImage = _mesa_select_tex_image(ctx, texObj, target, level);
-   if (!texImage) {
-      /* non-existant texture image */
+   if (!texImage ||
+       texImage->Width == 0 ||
+       texImage->Height == 0 ||
+       texImage->Depth == 0) {
+      /* non-existant or empty texture image */
        return GL_TRUE;
     }



-Brian


More information about the mesa-dev mailing list