vbo: limit number of warnings to 10
authorBrian Paul <brianp@vmware.com>
Thu, 24 Sep 2009 18:35:51 +0000 (12:35 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 24 Sep 2009 18:36:05 +0000 (12:36 -0600)
Otherwise some apps will emit tons of warnings.

src/mesa/vbo/vbo_exec_array.c

index 3f0656a..39c2957 100644 (file)
@@ -667,6 +667,7 @@ vbo_exec_DrawRangeElements(GLenum mode,
                           GLuint start, GLuint end,
                           GLsizei count, GLenum type, const GLvoid *indices)
 {
+   static GLuint warnCount = 0;
    GET_CURRENT_CONTEXT(ctx);
 
    if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
@@ -675,15 +676,19 @@ vbo_exec_DrawRangeElements(GLenum mode,
 
    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(start %u, end %u, count %d, "
-                    "type 0x%x, indices=%p)\n"
-                    "\tend is out of bounds (max=%u)  "
-                    "Element Buffer %u (size %d)\n"
-                    "\tThis should probably be fixed in the application.",
-                    start, end, count, type, indices,
-                    ctx->Array.ArrayObj->_MaxElement - 1,
-                    ctx->Array.ElementArrayBufferObj->Name,
-                    ctx->Array.ElementArrayBufferObj->Size);
+      warnCount++;
+
+      if (warnCount < 10) {
+         _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, "
+                       "type 0x%x, indices=%p)\n"
+                       "\tend is out of bounds (max=%u)  "
+                       "Element Buffer %u (size %d)\n"
+                       "\tThis should probably be fixed in the application.",
+                       start, end, count, type, indices,
+                       ctx->Array.ArrayObj->_MaxElement - 1,
+                       ctx->Array.ElementArrayBufferObj->Name,
+                       ctx->Array.ElementArrayBufferObj->Size);
+      }
 
       if (0)
          dump_element_buffer(ctx, type);
@@ -700,15 +705,17 @@ vbo_exec_DrawRangeElements(GLenum mode,
          GLuint max = _mesa_max_buffer_index(ctx, count, type, indices,
                                              ctx->Array.ElementArrayBufferObj);
          if (max >= ctx->Array.ArrayObj->_MaxElement) {
-            _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
-                          "count %d, type 0x%x, indices=%p)\n"
-                          "\tindex=%u is out of bounds (max=%u)  "
-                          "Element Buffer %u (size %d)\n"
-                          "\tSkipping the glDrawRangeElements() call",
-                          start, end, count, type, indices, max,
-                          ctx->Array.ArrayObj->_MaxElement - 1,
-                          ctx->Array.ElementArrayBufferObj->Name,
-                          ctx->Array.ElementArrayBufferObj->Size);
+            if (warnCount < 10) {
+               _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
+                             "count %d, type 0x%x, indices=%p)\n"
+                             "\tindex=%u is out of bounds (max=%u)  "
+                             "Element Buffer %u (size %d)\n"
+                             "\tSkipping the glDrawRangeElements() call",
+                             start, end, count, type, indices, max,
+                             ctx->Array.ArrayObj->_MaxElement - 1,
+                             ctx->Array.ElementArrayBufferObj->Name,
+                             ctx->Array.ElementArrayBufferObj->Size);
+            }
             return;
          }
          /* XXX we could also find the min index and compare to 'start'