[Mesa-dev] [PATCH] mesa: fix an issue with texture border and array textures

Brian Paul brianp at vmware.com
Thu Feb 16 06:59:54 PST 2012


On 02/15/2012 05:39 PM, Anuj Phogat wrote:
> As suggested by Brian, for a 1D texture array, the border only applies to
> the width. For a 2D texture array the border applies to the width and
> height but not to the depth.  This was not handled correctly in
> _mesa_init_teximage_fields().
>
> Note: This is a candidate for stable branches
>
> Signed-off-by: Anuj Phogat<anuj.phogat at gmail.com>
> ---
> Tested the patch with piglit quick.tests. No regressions.
>
>   src/mesa/main/teximage.c |    8 ++++++--
>   1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index e4eb7f6..d5f2650 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1083,11 +1083,13 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
>                              GLint border, GLenum internalFormat,
>                              gl_format format)
>   {
> +   GLenum target;
>      ASSERT(img);
>      ASSERT(width>= 0);
>      ASSERT(height>= 0);
>      ASSERT(depth>= 0);
>
> +   target = img->TexObject->Target;
>      img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
>      ASSERT(img->_BaseFormat>  0);
>      img->InternalFormat = internalFormat;
> @@ -1099,7 +1101,8 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
>      img->Width2 = width - 2 * border;   /* == 1<<  img->WidthLog2; */
>      img->WidthLog2 = _mesa_logbase2(img->Width2);
>
> -   if (height == 1) { /* 1-D texture */
> +   if (target ==  GL_TEXTURE_1D ||
> +       target ==  GL_TEXTURE_1D_ARRAY) { /* 1-D texture */
>         img->Height2 = 1;
>         img->HeightLog2 = 0;
>      }

That's not quite right.  If the texture is 1D_ARRAY, the Height2 value 
is the height w/out border.  So:

    if (target ==  GL_TEXTURE_1D) {
       img->Height2 = 1;
       img->HeightLog2 = 0;
    }
    else if (target ==  GL_TEXTURE_1D_ARRAY) {
       img->Height2 = height; /* no border */
       img->HeightLog2 = 0; /* not used */
    }
    else {
       img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
       img->HeightLog2 = _mesa_logbase2(img->Height2);
    }



> @@ -1108,7 +1111,8 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
>         img->HeightLog2 = _mesa_logbase2(img->Height2);
>      }
>
> -   if (depth == 1) {  /* 2-D texture */
> +   if (target == GL_TEXTURE_2D ||
> +       target == GL_TEXTURE_2D_ARRAY) {  /* 2-D texture */
>         img->Depth2 = 1;
>         img->DepthLog2 = 0;
>      }

Same thing as above: for TEXTURE_2D_ARRAY, Depth2 = depth.

-Brian


More information about the mesa-dev mailing list