Bug 758844 - Requiet gfx/gl code spew - r=bjacob
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 17 Jul 2012 08:26:12 -0700
changeset 99527 0888a88ab4c7327e906dc2ef8fae15e4408242bf
parent 99526 64ca6f0f5c9f960f3ea081a042d53ef5e86d7406
child 99528 9a6fcbd8f96aff59421cea1418c636b57c68593a
push id12044
push userjgilbert@mozilla.com
push dateTue, 17 Jul 2012 15:27:28 +0000
treeherdermozilla-inbound@0888a88ab4c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs758844
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 758844 - Requiet gfx/gl code spew - r=bjacob
gfx/gl/GLContext.cpp
gfx/gl/GLLibraryEGL.cpp
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -328,33 +328,33 @@ GLContext::InitWithPrefix(const char *pr
 
     // aborts on GL error. Can be useful to debug quicker code that is known not to generate any GL error in principle.
     if (PR_GetEnv("MOZ_GL_DEBUG_ABORT_ON_ERROR"))
         sDebugMode |= DebugAbortOnError;
 #endif
 
     if (mInitialized) {
 #ifdef DEBUG
-        static bool once = false;
-        if (DebugMode() && !once) {
+        static bool firstRun = true;
+        if (firstRun && DebugMode()) {
             const char *vendors[VendorOther] = {
                 "Intel",
                 "NVIDIA",
                 "ATI",
                 "Qualcomm"
             };
 
-            once = true;
             if (mVendor < VendorOther) {
                 printf_stderr("OpenGL vendor ('%s') recognized as: %s\n",
                               glVendorString, vendors[mVendor]);
             } else {
                 printf_stderr("OpenGL vendor ('%s') unrecognized\n", glVendorString);
             }
         }
+        firstRun = false;
 #endif
 
         InitExtensions();
 
         NS_ASSERTION(!IsExtensionSupported(GLContext::ARB_pixel_buffer_object) ||
                      (mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
                      "ARB_pixel_buffer_object supported without glMapBuffer/UnmapBuffer being available!");
 
@@ -535,27 +535,26 @@ void
 GLContext::InitExtensions()
 {
     MakeCurrent();
     const char* extensions = (const char*)fGetString(LOCAL_GL_EXTENSIONS);
     if (!extensions)
         return;
 
 #ifdef DEBUG
-    // If DEBUG, then be verbose the first time we're run.
-    static bool firstVerboseRun = true;
+    static bool firstRun = true;
 #else
     // Non-DEBUG, so never spew.
-    const bool firstVerboseRun = false;
+    const bool firstRun = false;
 #endif
 
-    mAvailableExtensions.Load(extensions, sExtensionNames, firstVerboseRun);
+    mAvailableExtensions.Load(extensions, sExtensionNames, firstRun && DebugMode());
 
 #ifdef DEBUG
-    firstVerboseRun = false;
+    firstRun = false;
 #endif
 }
 
 
 // Take texture data in a given buffer and copy it into a larger buffer,
 // padding out the edge pixels for filtering if necessary
 static void
 CopyAndPadTextureData(const GLvoid* srcBuffer,
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -4,16 +4,17 @@
 
 #include "GLLibraryEGL.h"
 
 #include "gfxCrashReporterUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsPrintfCString.h"
+#include "prenv.h"
 
 namespace mozilla {
 namespace gl {
 
 // should match the order of EGLExtensions, and be null-terminated.
 static const char *sExtensionNames[] = {
     "EGL_KHR_image_base",
     "EGL_KHR_image_pixmap",
@@ -275,33 +276,31 @@ GLLibraryEGL::InitExtensions()
 {
     const char *extensions = (const char*)fQueryString(mEGLDisplay, LOCAL_EGL_EXTENSIONS);
 
     if (!extensions) {
         NS_WARNING("Failed to load EGL extension list!");
         return;
     }
 
+    bool debugMode = false;
 #ifdef DEBUG
-    // If DEBUG, then be verbose the first time we're run.
-    static bool firstVerboseRun = true;
+    if (PR_GetEnv("MOZ_GL_DEBUG"))
+        debugMode = true;
+
+    static bool firstRun = true;
 #else
     // Non-DEBUG, so never spew.
-    const bool firstVerboseRun = false;
+    const bool firstRun = false;
 #endif
 
-    if (firstVerboseRun) {
-        printf_stderr("Extensions: %s 0x%02x\n", extensions, extensions[0]);
-        printf_stderr("Extensions length: %d\n", strlen(extensions));
-    }
-
-    mAvailableExtensions.Load(extensions, sExtensionNames, firstVerboseRun);
+    mAvailableExtensions.Load(extensions, sExtensionNames, firstRun && debugMode);
 
 #ifdef DEBUG
-    firstVerboseRun = false;
+    firstRun = false;
 #endif
 }
 
 void
 GLLibraryEGL::LoadConfigSensitiveSymbols()
 {
     GLLibraryLoader::PlatformLookupFunction lookupFunction =
             (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;