aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-07-15 13:29:58 +0100
committerKeith Whitwell <[email protected]>2009-07-15 13:31:51 +0100
commitfdeb77899052302053459b8a840a747346e30468 (patch)
tree333a25e0f5a8376041e96fc96a19d82121b52bdd /src/mesa/main
parent59de430de70c38a2fbe30208190f725a2901613c (diff)
mesa: recognize and eliminate repeated error messages
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/imports.c34
-rw-r--r--src/mesa/main/mtypes.h7
2 files changed, 38 insertions, 3 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 3916c62eda3..1722579e82c 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1021,6 +1021,22 @@ output_if_debug(const char *prefixString, const char *outputString,
}
}
+static const char *error_string( GLenum error );
+
+static void flush_delayed_errors( GLcontext *ctx )
+{
+ char s2[MAXSTRING];
+
+ if (ctx->ErrorDebugCount) {
+ _mesa_snprintf(s2, MAXSTRING, "%d similar %s errors",
+ ctx->ErrorDebugCount,
+ error_string(ctx->ErrorValue));
+
+ output_if_debug("Mesa: ", s2, GL_TRUE);
+
+ ctx->ErrorDebugCount = 0;
+ }
+}
/**
* Report a warning (a recoverable error condition) to stderr if
@@ -1034,10 +1050,12 @@ _mesa_warning( GLcontext *ctx, const char *fmtString, ... )
{
char str[MAXSTRING];
va_list args;
- (void) ctx;
va_start( args, fmtString );
(void) vsnprintf( str, MAXSTRING, fmtString, args );
va_end( args );
+
+ if (ctx)
+ flush_delayed_errors( ctx );
output_if_debug("Mesa warning", str, GL_TRUE);
}
@@ -1126,16 +1144,26 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
#endif
}
- if (debug) {
- {
+ if (debug) {
+ if (ctx->ErrorValue == error &&
+ ctx->ErrorDebugFmtString == fmtString) {
+ ctx->ErrorDebugCount++;
+ }
+ else {
char s[MAXSTRING], s2[MAXSTRING];
va_list args;
+
+ flush_delayed_errors( ctx );
+
va_start(args, fmtString);
vsnprintf(s, MAXSTRING, fmtString, args);
va_end(args);
_mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s);
output_if_debug("Mesa: User error", s2, GL_TRUE);
+
+ ctx->ErrorDebugFmtString = fmtString;
+ ctx->ErrorDebugCount = 0;
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index bdaa4977b72..3b0ebcb7aef 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2955,6 +2955,13 @@ struct __GLcontextRec
#endif
GLenum ErrorValue; /**< Last error code */
+
+ /**
+ * Recognize and silence repeated error debug messages in buggy apps.
+ */
+ const char *ErrorDebugFmtString;
+ GLuint ErrorDebugCount;
+
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
GLbitfield NewState; /**< bitwise-or of _NEW_* flags */