Bug 785734 - WebGL: test for illegal texture sizes for given mipmap level - r=jgilbert
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 09 Oct 2012 14:21:22 -0400
changeset 109768 81675e760c1229669a5e620e6ffd1f8d762882c3
parent 109767 f468573e0725553ad76546cd3d6ce0c22b69c6e5
child 109769 3e0deee3c6fda70397d668c3013098ba6aaafdf7
push id23652
push userryanvm@gmail.com
push dateWed, 10 Oct 2012 01:10:20 +0000
treeherdermozilla-central@5cca0408a73f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs785734
milestone19.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 785734 - WebGL: test for illegal texture sizes for given mipmap level - r=jgilbert
content/canvas/src/WebGLContextGL.cpp
content/canvas/src/WebGLContextValidate.cpp
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -673,34 +673,16 @@ WebGLContext::CopyTexSubImage2D_base(Web
 
     MakeContextCurrent();
 
     WebGLTexture *tex = activeBoundTextureForTarget(target);
 
     if (!tex)
         return ErrorInvalidOperation("%s: no texture is bound to this target");
 
-#ifdef MOZ_X11
-    // bug 785734
-    if (gl->WorkAroundDriverBugs() &&
-        mIsMesa &&
-        level > 0 &&
-        !sub)
-    {
-        size_t face = WebGLTexture::FaceForTarget(target);
-        if (!tex->HasImageInfoAt(0, face) ||
-            tex->ImageInfoAt(0, face).Width() <= width)
-        {
-            return  ErrorInvalidOperation("%s: rejecting valid call to avoid Mesa driver crash. "
-                                          "See Mozilla bug 785734",
-                                          info);
-        }
-    }
-#endif
-
     if (CanvasUtils::CheckSaneSubrectSize(x, y, width, height, framebufferWidth, framebufferHeight)) {
         if (sub)
             gl->fCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
         else
             gl->fCopyTexImage2D(target, level, internalformat, x, y, width, height, 0);
     } else {
 
         // the rect doesn't fit in the framebuffer
@@ -4672,32 +4654,16 @@ WebGLContext::TexImage2D_base(WebGLenum 
         return ErrorInvalidOperation("texImage2D: no texture is bound to this target");
 
     MakeContextCurrent();
 
     // Handle ES2 and GL differences in floating point internal formats.  Note that
     // format == internalformat, as checked above and as required by ES.
     internalformat = InternalFormatForFormatAndType(format, type, gl->IsGLES2());
 
-#ifdef MOZ_X11
-    // bug 785734
-    if (gl->WorkAroundDriverBugs() &&
-        mIsMesa &&
-        level > 0)
-    {
-        size_t face = WebGLTexture::FaceForTarget(target);
-        if (!tex->HasImageInfoAt(0, face) ||
-            tex->ImageInfoAt(0, face).Width() <= width)
-        {
-            return  ErrorInvalidOperation("texImage2D: rejecting valid call to avoid Mesa driver crash. "
-                                          "See Mozilla bug 785734");
-        }
-    }
-#endif
-
     GLenum error = LOCAL_GL_NO_ERROR;
 
     if (byteLength) {
         size_t srcStride = srcStrideOrZero ? srcStrideOrZero : checked_alignedRowSize.value();
 
         size_t dstPlainRowSize = dstTexelSize * width;
         size_t unpackAlignment = mPixelStoreUnpackAlignment;
         size_t dstStride = ((dstPlainRowSize + unpackAlignment-1) / unpackAlignment) * unpackAlignment;
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -459,28 +459,30 @@ bool WebGLContext::ValidateLevelWidthHei
 {
     WebGLsizei maxTextureSize = MaxTextureSizeForTarget(target);
 
     if (level < 0) {
         ErrorInvalidValue("%s: level must be >= 0", info);
         return false;
     }
 
-    if (!(maxTextureSize >> level)) {
+    WebGLsizei maxAllowedSize = maxTextureSize >> level;
+
+    if (!maxAllowedSize) {
         ErrorInvalidValue("%s: 2^level exceeds maximum texture size", info);
         return false;
     }
 
     if (width < 0 || height < 0) {
         ErrorInvalidValue("%s: width and height must be >= 0", info);
         return false;
     }
 
-    if (width > maxTextureSize || height > maxTextureSize) {
-        ErrorInvalidValue("%s: width or height exceeds maximum texture size", info);
+    if (width > maxAllowedSize || height > maxAllowedSize) {
+        ErrorInvalidValue("%s: the maximum texture size for level %d is %d", info, level, maxAllowedSize);
         return false;
     }
 
     return true;
 }
 
 uint32_t WebGLContext::GetBitsPerTexel(WebGLenum format, WebGLenum type)
 {