Bug 832576 - Fix perf regression in WebGL uniform setters. r=jgilbert, a=akeybl
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 25 Jan 2013 13:40:38 -0500
changeset 127334 a83f24162110fb15c816416353685c42ecb8d044
parent 127333 ca21e77bb5e7cec1b0c4c48c0ba41a0cf6a15e09
child 127335 f4f89f5b0d0fa4240bb7e6d252260190d9949bd7
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, akeybl
bugs832576
milestone20.0a2
Bug 832576 - Fix perf regression in WebGL uniform setters. r=jgilbert, a=akeybl
content/canvas/src/WebGLContextValidate.cpp
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -702,40 +702,37 @@ WebGLContext::ValidateAttribArraySetter(
 }
 
 bool
 WebGLContext::ValidateUniformArraySetter(const char* name, uint32_t expectedElemSize, WebGLUniformLocation *location_object,
                                          GLint& location, uint32_t& numElementsToUpload, uint32_t arrayLength)
 {
     if (!IsContextStable())
         return false;
-    nsCString nameString(name);
-    nsCString suffix = NS_LITERAL_CSTRING(": location");
-    nsCString concatenated = nameString + suffix;
-    if (!ValidateUniformLocation(concatenated.get(), location_object))
+    if (!ValidateUniformLocation(name, location_object))
         return false;
     location = location_object->Location();
     uint32_t uniformElemSize = location_object->ElementSize();
     if (expectedElemSize != uniformElemSize) {
         ErrorInvalidOperation("%s: this function expected a uniform of element size %d,"
                               " got a uniform of element size %d", name,
                               expectedElemSize,
                               uniformElemSize);
         return false;
     }
-    const WebGLUniformInfo& info = location_object->Info();
     if (arrayLength == 0 ||
         arrayLength % expectedElemSize)
     {
         ErrorInvalidValue("%s: expected an array of length a multiple"
                           " of %d, got an array of length %d", name,
                           expectedElemSize,
                           arrayLength);
         return false;
     }
+    const WebGLUniformInfo& info = location_object->Info();
     if (!info.isArray &&
         arrayLength != expectedElemSize) {
         ErrorInvalidOperation("%s: expected an array of length exactly"
                               " %d (since this uniform is not an array"
                               " uniform), got an array of length %d", name,
                               expectedElemSize,
                               arrayLength);
         return false;
@@ -748,40 +745,37 @@ WebGLContext::ValidateUniformArraySetter
 bool
 WebGLContext::ValidateUniformMatrixArraySetter(const char* name, int dim, WebGLUniformLocation *location_object,
                                               GLint& location, uint32_t& numElementsToUpload, uint32_t arrayLength,
                                               WebGLboolean aTranspose)
 {
     uint32_t expectedElemSize = (dim)*(dim);
     if (!IsContextStable())
         return false;
-    nsCString nameString(name);
-    nsCString suffix = NS_LITERAL_CSTRING(": location");
-    nsCString concatenated = nameString + suffix;
-    if (!ValidateUniformLocation(concatenated.get(), location_object))
+    if (!ValidateUniformLocation(name, location_object))
         return false;
     location = location_object->Location();
     uint32_t uniformElemSize = location_object->ElementSize();
     if (expectedElemSize != uniformElemSize) {
         ErrorInvalidOperation("%s: this function expected a uniform of element size %d,"
                               " got a uniform of element size %d", name,
                               expectedElemSize,
                               uniformElemSize);
         return false;
     }
-    const WebGLUniformInfo& info = location_object->Info();
     if (arrayLength == 0 ||
         arrayLength % expectedElemSize)
     {
         ErrorInvalidValue("%s: expected an array of length a multiple"
                           " of %d, got an array of length %d", name,
                           expectedElemSize,
                           arrayLength);
         return false;
     }
+    const WebGLUniformInfo& info = location_object->Info();
     if (!info.isArray &&
         arrayLength != expectedElemSize) {
         ErrorInvalidOperation("%s: expected an array of length exactly"
                               " %d (since this uniform is not an array"
                               " uniform), got an array of length %d", name,
                               expectedElemSize,
                               arrayLength);
         return false;
@@ -796,20 +790,17 @@ WebGLContext::ValidateUniformMatrixArray
     return true;
 }
 
 bool
 WebGLContext::ValidateUniformSetter(const char* name, WebGLUniformLocation *location_object, GLint& location)
 {
     if (!IsContextStable())
         return false;
-    nsCString nameString(name);
-    nsCString suffix = NS_LITERAL_CSTRING(": location");
-    nsCString concatenated = nameString + suffix;
-    if (!ValidateUniformLocation(concatenated.get(), location_object))
+    if (!ValidateUniformLocation(name, location_object))
         return false;
     location = location_object->Location();
     return true;
 }
 
 bool WebGLContext::ValidateAttribIndex(WebGLuint index, const char *info)
 {
     if (index >= mAttribBuffers.Length()) {