Bug 1324712 - TEXTURE_2D_ARRAY mipmap checks are wrong. - r=daoshengmu
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 20 Dec 2016 00:21:55 -0800
changeset 357452 fbb8675a7c60226c3af4fbd767bbaa2d4281c4e8
parent 357451 d4e72a2264ebbeed883e5e0b857d61bcecf8af13
child 357453 abb9dd41410e3d06207446a59fdb3ff6c8a98f5a
push id17
push userfmarier@mozilla.com
push dateFri, 13 Jan 2017 22:14:57 +0000
reviewersdaoshengmu
bugs1324712
milestone53.0a1
Bug 1324712 - TEXTURE_2D_ARRAY mipmap checks are wrong. - r=daoshengmu MozReview-Commit-ID: 81dEFSATPgR
dom/canvas/WebGLTexture.cpp
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -233,26 +233,36 @@ WebGLTexture::IsMipmapComplete(uint32_t 
                 cur.mFormat != baseImageInfo.mFormat)
             {
                 return false;
             }
         }
 
         // GLES 3.0.4, p158:
         // "[...] until the last array is reached with dimension 1 x 1 x 1."
-        if (refWidth == 1 &&
-            refHeight == 1 &&
-            refDepth == 1)
-        {
-            break;
+        if (mTarget == LOCAL_GL_TEXTURE_3D) {
+            if (refWidth == 1 &&
+                refHeight == 1 &&
+                refDepth == 1)
+            {
+                break;
+            }
+
+            refDepth = std::max(uint32_t(1), refDepth / 2);
+        } else {
+            // TEXTURE_2D_ARRAY may have depth != 1, but that's normal.
+            if (refWidth == 1 &&
+                refHeight == 1)
+            {
+                break;
+            }
         }
 
         refWidth  = std::max(uint32_t(1), refWidth  / 2);
         refHeight = std::max(uint32_t(1), refHeight / 2);
-        refDepth  = std::max(uint32_t(1), refDepth  / 2);
     }
 
     return true;
 }
 
 bool
 WebGLTexture::IsCubeComplete() const
 {