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

Jason Ekstrand jason at jlekstrand.net
Wed Sep 2 10:33:01 PDT 2015


On Sep 2, 2015 7:27 AM, "Ilia Mirkin" <imirkin at alum.mit.edu> wrote:
>
> On Wed, Sep 2, 2015 at 6:29 AM, 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.
> >
> > v2: Also check for width == 0. Don't validate the start pointer if any
> >     of the dimensions are zero.
>
> Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
>
> Note that the spec text you referred to earlier said to error if
> anything out of bounds *would be accessed*, but if any of the dims are
> 0, then nothing is accessed...

We can probably just bail higher up in the stack and never call the driver
hook if we have a zero dimension.  That would also protect us from silly
zero-dim bugs that may exist.

> > ---
> >  src/mesa/main/pbo.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c
> > index 0c16025..7762324 100644
> > --- a/src/mesa/main/pbo.c
> > +++ b/src/mesa/main/pbo.c
> > @@ -103,6 +103,12 @@ _mesa_validate_pbo_access(GLuint dimensions,
> >        /* no buffer! */
> >        return GL_FALSE;
> >
> > +   /* If the size of the image is zero then no pixels are accessed so
we
> > +    * don't need to check anything else.
> > +    */
> > +   if (width == 0 || height == 0 || depth == 0)
> > +      return GL_TRUE;
> > +
> >     /* get the offset to the first pixel we'll read/write */
> >     start = _mesa_image_offset(dimensions, pack, width, height,
> >                                format, type, 0, 0, 0);
> > --
> > 1.9.3
> >
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150902/61b28f37/attachment-0001.html>


More information about the mesa-dev mailing list