mesa: Handle zero-stride arrays in _mesa_update_array_max_element()
authorFredrik Höglund <fredrik@kde.org>
Thu, 4 Apr 2013 17:55:50 +0000 (19:55 +0200)
committerFredrik Höglund <fredrik@kde.org>
Thu, 7 Nov 2013 15:20:45 +0000 (16:20 +0100)
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/varray.h

index a75cb7db8ea38e9a64b6c29869f4869129d6512b..8a9487c6e6cd40156ac4c0c30de769ae751d8da1 100644 (file)
@@ -51,8 +51,10 @@ _mesa_update_array_max_element(struct gl_client_array *array)
       GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size;
 
       if (offset < bufSize) {
-        array->_MaxElement = (bufSize - offset + array->StrideB
-                               - array->_ElementSize) / array->StrideB;
+         const GLuint stride = array->StrideB ?
+                                 array->StrideB : array->_ElementSize;
+         array->_MaxElement = (bufSize - offset + stride
+                                  - array->_ElementSize) / stride;
       }
       else {
         array->_MaxElement = 0;