From: Neil Roberts Date: Wed, 2 Sep 2015 10:29:16 +0000 (+0100) Subject: mesa/pbo: Handle zero width, height or depth when validating access X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce181aea6cb5353181add7b5aca3c0b196a9b513;p=mesa.git mesa/pbo: Handle zero width, height or depth when validating access 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 --- diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 0c160253201..7762324a4ae 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);