[Mesa-dev] [PATCH] mesa/pbo: Handle zero height or depth when validating PBO access

Ilia Mirkin imirkin at alum.mit.edu
Tue Sep 1 10:50:11 PDT 2015


On Tue, Sep 1, 2015 at 1:40 PM, Neil Roberts <neil at linux.intel.com> wrote:
> It's legal to call glTexSubImage with zero values for the width,
> height or depth. Previously this was breaking the PBO access
> validation because it tries to work out the last pixel accessed by
> getting the pixel at height-1 and depth-1 which would end up with
> bogus values.
>
> This was causing GL errors to be generated during the Piglit
> texsubimage test, although the test was passing anyway.
> ---
>  src/mesa/main/pbo.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c
> index 0c16025..f71cbc0 100644
> --- a/src/mesa/main/pbo.c
> +++ b/src/mesa/main/pbo.c
> @@ -108,8 +108,11 @@ _mesa_validate_pbo_access(GLuint dimensions,
>                                format, type, 0, 0, 0);
>
>     /* get the offset to just past the last pixel we'll read/write */
> -   end =  _mesa_image_offset(dimensions, pack, width, height,
> -                             format, type, depth-1, height-1, width);
> +   if (depth == 0 || height == 0)

Why not width == 0 as well? You could probably just do

  return GL_TRUE;

in that case as well, and then call _mesa_image_offset unconditionally
for both end/start. IMHO simpler and more efficient.

> +      end = start;
> +   else
> +      end =  _mesa_image_offset(dimensions, pack, width, height,

I've always found a single space is enough for me... apparently not
for the original author of this code (which you then just indented).

> +                                format, type, depth-1, height-1, width);
>
>     start += offset;
>     end += offset;
> --
> 1.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list