Bug 1305832 - Only use ZeroTexImageWithClear if we really have to. - r=ethlin
☠☠ backed out by 0a3b96cee2ea ☠ ☠
authorJeff Gilbert <jdashg@gmail.com>
Tue, 27 Sep 2016 12:54:56 -0700
changeset 324950 5b70ccd12b426848e5cb65213d19d078278ec8ba
parent 324949 22f11c60991cdd765baf5767c5066dfcc9990186
child 324951 f97b53fd3b7e0728c555efd145765879bda1b950
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersethlin
bugs1305832
milestone53.0a1
Bug 1305832 - Only use ZeroTexImageWithClear if we really have to. - r=ethlin Only needed for ANGLE_depth_texture.
dom/canvas/WebGLContext.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -2251,16 +2251,18 @@ ZeroTexImageWithClear(WebGLContext* webg
                                  : LOCAL_GL_STENCIL_ATTACHMENT);
         clearBits |= LOCAL_GL_STENCIL_BUFFER_BIT;
     }
 
     MOZ_RELEASE_ASSERT(attachPoint && clearBits, "GFX: No bits cleared.");
 
     {
         gl::GLContext::LocalErrorScope errorScope(*gl);
+        MOZ_ASSERT(target != LOCAL_GL_TEXTURE_2D_ARRAY &&
+                   target != LOCAL_GL_TEXTURE_3D);
         gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, attachPoint, target.get(), tex,
                                   level);
         if (errorScope.GetError()) {
             MOZ_ASSERT(false);
             return false;
         }
     }
 
@@ -2358,28 +2360,22 @@ ZeroTextureData(WebGLContext* webgl, con
             return false;
 
         return true;
     }
 
     const auto driverUnpackInfo = usage->idealUnpack;
     MOZ_RELEASE_ASSERT(driverUnpackInfo, "GFX: ideal unpack info not set.");
 
-    if (usage->IsRenderable() && depth == 1 &&
-        !xOffset && !yOffset && !zOffset)
-    {
-        // While we would like to skip the extra complexity of trying to zero with an FB
-        // clear, ANGLE_depth_texture requires this.
-        do {
-            if (ZeroTexImageWithClear(webgl, gl, target, tex, level, usage, width,
-                                      height))
-            {
-                return true;
-            }
-        } while (false);
+    if (!webgl->IsWebGL2() && usage->format->d) {
+        // ANGLE_depth_texture does not allow uploads, so we have to clear.
+        const bool success = ZeroTexImageWithClear(webgl, gl, target, tex, level, usage,
+                                                   width, height);
+        MOZ_ASSERT(success);
+        return success;
     }
 
     const webgl::PackingInfo packing = driverUnpackInfo->ToPacking();
 
     const auto bytesPerPixel = webgl::BytesPerPixel(packing);
 
     CheckedUint32 checkedByteCount = bytesPerPixel;
     checkedByteCount *= width;