Mesa (master): vbo: limit number of warnings to 10

Brian Paul brianp at kemper.freedesktop.org
Thu Sep 24 22:07:06 UTC 2009


Module: Mesa
Branch: master
Commit: 1a816117258e594a073f6925edfcd2387071904d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a816117258e594a073f6925edfcd2387071904d

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Sep 24 12:35:51 2009 -0600

vbo: limit number of warnings to 10

Otherwise some apps will emit tons of warnings.

---

 src/mesa/vbo/vbo_exec_array.c |   43 +++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 3f0656a..39c2957 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -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'




More information about the mesa-commit mailing list