[Mesa-dev] [PATCH] Correct test for depth parameter for checking if dimension is legal

Ian Romanick idr at freedesktop.org
Mon Jan 27 11:40:18 PST 2014


On 01/27/2014 03:16 AM, Kevin Rogovin wrote:
> Fixes the tests for the depth parameter for TexImage3D calls when the
> target type is GL_TEXTURE_2D_ARRAY or GL_TEXTURE_CUBE_MAP_ARRAY
> so that a depth value of 0 is accepted. Previously, the check
> incorrectly required the depth argument to be atleast 1. 

Oof.  It looks like that function could use some significant
refactoring.  This patch, however, is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

We should also have a piglit test that tries various combinations of
width / height / depth being zero.

> ---
>  src/mesa/main/teximage.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 9c3f1e8..8e2f057 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1481,7 +1481,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
>           return GL_FALSE;
>        if (height < 2 * border || height > 2 * border + maxSize)
>           return GL_FALSE;
> -      if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers)
> +      if (depth < 0 || depth > ctx->Const.MaxArrayTextureLayers)
>           return GL_FALSE;
>        if (!ctx->Extensions.ARB_texture_non_power_of_two) {
>           if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
> @@ -1498,7 +1498,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
>           return GL_FALSE;
>        if (height < 2 * border || height > 2 * border + maxSize)
>           return GL_FALSE;
> -      if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers || depth % 6)
> +      if (depth < 0 || depth > ctx->Const.MaxArrayTextureLayers || depth % 6)
>           return GL_FALSE;
>        if (width != height)
>           return GL_FALSE;
> 



More information about the mesa-dev mailing list