Bug 879304 - Add "webgl.max-warnings-per-context" preference. r=bjacob
authorGuillaume Abadie <gabadie@mozilla.com>
Tue, 04 Jun 2013 15:44:08 -0400
changeset 133955 f8c2a4b9971c0b6269e092a48f770ff0b9ed871e
parent 133954 950ab2f55a1a1eddc8b91fa98fb2bd33ed85998f
child 133956 c3dc266f985ee896739007011d7a55431d185bf6
push id28985
push userryanvm@gmail.com
push dateTue, 04 Jun 2013 19:44:08 +0000
treeherdermozilla-inbound@f8c2a4b9971c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs879304
milestone24.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 879304 - Add "webgl.max-warnings-per-context" preference. r=bjacob
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContext.h
modules/libpref/src/init/all.js
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -184,16 +184,22 @@ WebGLContext::WebGLContext()
     mContextRestorer = do_CreateInstance("@mozilla.org/timer;1");
     mContextStatus = ContextStable;
     mContextLostErrorSet = false;
     mLoseContextOnHeapMinimize = false;
     mCanLoseContextInForeground = true;
 
     mAlreadyGeneratedWarnings = 0;
     mAlreadyWarnedAboutFakeVertexAttrib0 = false;
+    mMaxWarnings = Preferences::GetInt("webgl.max-warnings-per-context", 32);
+    if (mMaxWarnings < -1)
+    {
+        GenerateWarning("webgl.max-warnings-per-context size is too large (seems like a negative value wrapped)");
+        mMaxWarnings = 0;
+    }
 
     mLastUseIndex = 0;
 
     mMinInUseAttribArrayLengthCached = false;
     mMinInUseAttribArrayLength = 0;
 
     mIsScreenCleared = false;
 
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -1129,20 +1129,25 @@ protected:
     ContextStatus mContextStatus;
     bool mContextLostErrorSet;
 
     // Used for some hardware (particularly Tegra 2 and 4) that likes to
     // be Flushed while doing hundreds of draw calls.
     int mDrawCallsSinceLastFlush;
 
     int mAlreadyGeneratedWarnings;
+    int mMaxWarnings;
     bool mAlreadyWarnedAboutFakeVertexAttrib0;
 
     bool ShouldGenerateWarnings() const {
-        return mAlreadyGeneratedWarnings < 32;
+        if (mMaxWarnings == -1) {
+            return true;
+        }
+
+        return mAlreadyGeneratedWarnings < mMaxWarnings;
     }
 
     uint64_t mLastUseIndex;
 
     void LoseOldestWebGLContextIfLimitExceeded();
     void UpdateLastUseIndex();
 
     template <typename WebGLObjectType>
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -3957,16 +3957,17 @@ pref("webgl.prefer-native-gl", false);
 pref("webgl.min_capability_mode", false);
 pref("webgl.disable-extensions", false);
 pref("webgl.msaa-force", false);
 pref("webgl.prefer-16bpp", false);
 pref("webgl.default-no-alpha", false);
 pref("webgl.force-layers-readback", false);
 pref("webgl.lose-context-on-heap-minimize", false);
 pref("webgl.can-lose-context-in-foreground", true);
+pref("webgl.max-warnings-per-context", 32);
 
 // Stagefright prefs
 pref("stagefright.force-enabled", false);
 pref("stagefright.disabled", false);
 
 #ifdef XP_WIN
 // The default TCP send window on Windows is too small, and autotuning only occurs on receive
 pref("network.tcp.sendbuffer", 131072);