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

Neil Roberts neil at linux.intel.com
Tue Sep 1 10:40:39 PDT 2015


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)
+      end = start;
+   else
+      end =  _mesa_image_offset(dimensions, pack, width, height,
+                                format, type, depth-1, height-1, width);
 
    start += offset;
    end += offset;
-- 
1.9.3



More information about the mesa-dev mailing list