OSDN Git Service

mesa: move gl_array_attrib::_MaxElement to gl_array_object::_MaxElement
authorBrian Paul <brianp@vmware.com>
Thu, 14 May 2009 19:24:24 +0000 (13:24 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 21 May 2009 15:17:08 +0000 (09:17 -0600)
This value is per array object.

src/mesa/main/api_validate.c
src/mesa/main/mtypes.h
src/mesa/main/state.c
src/mesa/vbo/vbo_exec_array.c

index d5c604c..1507671 100644 (file)
@@ -182,10 +182,10 @@ _mesa_validate_DrawElements(GLcontext *ctx,
       /* find max array index */
       GLuint max = max_buffer_index(ctx, count, type, indices,
                                     ctx->Array.ElementArrayBufferObj);
-      if (max >= ctx->Array._MaxElement) {
+      if (max >= ctx->Array.ArrayObj->_MaxElement) {
          /* the max element is out of bounds of one or more enabled arrays */
          _mesa_warning(ctx, "glDrawElements() index=%u is "
-                       "out of bounds (max=%u)", max, ctx->Array._MaxElement);
+                       "out of bounds (max=%u)", max, ctx->Array.ArrayObj->_MaxElement);
          return GL_FALSE;
       }
    }
@@ -254,7 +254,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
    if (ctx->Const.CheckArrayBounds) {
       GLuint max = max_buffer_index(ctx, count, type, indices,
                                     ctx->Array.ElementArrayBufferObj);
-      if (max >= ctx->Array._MaxElement) {
+      if (max >= ctx->Array.ArrayObj->_MaxElement) {
          /* the max element is out of bounds of one or more enabled arrays */
          return GL_FALSE;
       }
@@ -293,7 +293,7 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
       return GL_FALSE;
 
    if (ctx->Const.CheckArrayBounds) {
-      if (start + count > (GLint) ctx->Array._MaxElement)
+      if (start + count > (GLint) ctx->Array.ArrayObj->_MaxElement)
          return GL_FALSE;
    }
 
index d11df53..0df425c 100644 (file)
@@ -1578,6 +1578,12 @@ struct gl_array_object
 
    /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */
    GLbitfield _Enabled;
+
+   /**
+    * Min of all enabled arrays' _MaxElement.  When arrays reside inside VBOs
+    * we can determine the max legal (in bounds) glDrawElements array index.
+    */
+   GLuint _MaxElement;
 };
 
 
@@ -1602,7 +1608,6 @@ struct gl_array_attrib
    struct gl_buffer_object *ArrayBufferObj;
    struct gl_buffer_object *ElementArrayBufferObj;
 #endif
-   GLuint _MaxElement;          /* Min of all enabled array's maxes */
 };
 
 
index a6411f7..bfbefa5 100644 (file)
@@ -206,7 +206,7 @@ update_arrays( GLcontext *ctx )
    }
 
    /* _MaxElement is one past the last legal array element */
-   ctx->Array._MaxElement = min;
+   arrayObj->_MaxElement = min;
 }
 
 
index fdb5018..a4c67c1 100644 (file)
@@ -352,10 +352,11 @@ vbo_exec_DrawRangeElements(GLenum mode,
    if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, type, indices ))
       return;
 
-   if (end >= ctx->Array._MaxElement) {
+   if (end >= ctx->Array.ArrayObj->_MaxElement) {
       /* the max element is out of bounds of one or more enabled arrays */
       _mesa_warning(ctx, "glDraw[Range]Elements() index=%u is "
-                    "out of bounds (max=%u)", end, ctx->Array._MaxElement);
+                    "out of bounds (max=%u)", end,
+                    ctx->Array.ArrayObj->_MaxElement);
       return;
    }