summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/imports.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 3fb67083a2d..b0e7d9d4835 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1081,22 +1081,25 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
void
_mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
{
- const char *debugEnv;
- GLboolean debug;
+ static GLint debug = -1;
- debugEnv = _mesa_getenv("MESA_DEBUG");
+ /* Check debug environment variable only once:
+ */
+ if (debug == -1) {
+ const char *debugEnv = _mesa_getenv("MESA_DEBUG");
#ifdef DEBUG
- if (debugEnv && _mesa_strstr(debugEnv, "silent"))
- debug = GL_FALSE;
- else
- debug = GL_TRUE;
+ if (debugEnv && _mesa_strstr(debugEnv, "silent"))
+ debug = GL_FALSE;
+ else
+ debug = GL_TRUE;
#else
- if (debugEnv)
- debug = GL_TRUE;
- else
- debug = GL_FALSE;
+ if (debugEnv)
+ debug = GL_TRUE;
+ else
+ debug = GL_FALSE;
#endif
+ }
if (debug) {
va_list args;