Bug 1290634 - Remove unnecessary respecifyTexture arg from ZeroTextureData. - r=mtseng
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 29 Jul 2016 18:19:19 -0700
changeset 309344 f234bc22c1bfef13ceed22c3bb1de1a280aab733
parent 309343 204eae54f875f73c337013c1f3b1bf9de7c5d14f
child 309345 1bcfbe7fc1e8e34cefffd0d2051eb7ff91fe1d70
push id30561
push userkwierso@gmail.com
push dateMon, 15 Aug 2016 21:20:49 +0000
treeherdermozilla-central@91a319101587 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmtseng
bugs1290634
milestone51.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 1290634 - Remove unnecessary respecifyTexture arg from ZeroTextureData. - r=mtseng MozReview-Commit-ID: 52VirsA4eCQ
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLTexture.cpp
dom/canvas/WebGLTextureUpload.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -2177,18 +2177,18 @@ ZeroTexImageWithClear(WebGLContext* webg
             return false;
         }
     }
 
     return true;
 }
 
 bool
-ZeroTextureData(WebGLContext* webgl, const char* funcName, bool respecifyTexture,
-                GLuint tex, TexImageTarget target, uint32_t level,
+ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
+                TexImageTarget target, uint32_t level,
                 const webgl::FormatUsageInfo* usage, uint32_t xOffset, uint32_t yOffset,
                 uint32_t zOffset, uint32_t width, uint32_t height, uint32_t depth)
 {
     // This has two usecases:
     // 1. Lazy zeroing of uninitialized textures:
     //    a. Before draw, when FakeBlack isn't viable. (TexStorage + Draw*)
     //    b. Before partial upload. (TexStorage + TexSubImage)
     // 2. Zero subrects from out-of-bounds blits. (CopyTex(Sub)Image)
@@ -2201,17 +2201,16 @@ ZeroTextureData(WebGLContext* webgl, con
                            funcName);
 
     gl::GLContext* gl = webgl->GL();
     gl->MakeCurrent();
 
     auto compression = usage->format->compression;
     if (compression) {
         MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset, "GFX: Can't zero compressed texture with offsets.");
-        MOZ_RELEASE_ASSERT(!respecifyTexture, "GFX: respecifyTexture is set to true.");
 
         auto sizedFormat = usage->format->sizedFormat;
         MOZ_RELEASE_ASSERT(sizedFormat, "GFX: texture sized format not set");
 
         const auto fnSizeInBlocks = [](CheckedUint32 pixels, uint8_t pixelsPerBlock) {
             return RoundUpToMultipleOf(pixels, pixelsPerBlock) / pixelsPerBlock;
         };
 
@@ -2249,23 +2248,16 @@ ZeroTextureData(WebGLContext* webgl, con
     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 (respecifyTexture) {
-                const auto error = DoTexImage(gl, target, level, driverUnpackInfo, width,
-                                              height, depth, nullptr);
-                if (error)
-                    break;
-            }
-
             if (ZeroTexImageWithClear(webgl, gl, target, tex, level, usage, width,
                                       height))
             {
                 return true;
             }
         } while (false);
     }
 
@@ -2285,25 +2277,18 @@ ZeroTextureData(WebGLContext* webgl, con
 
     UniqueBuffer zeros = calloc(1, byteCount);
     if (!zeros)
         return false;
 
     ScopedUnpackReset scopedReset(webgl);
     gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1); // Don't bother with striding it well.
 
-    GLenum error;
-    if (respecifyTexture) {
-        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset, "GFX: texture data, offsets, not zeroed.");
-        error = DoTexImage(gl, target, level, driverUnpackInfo, width, height, depth,
-                           zeros.get());
-    } else {
-        error = DoTexSubImage(gl, target, level, xOffset, yOffset, zOffset, width, height,
-                              depth, packing, zeros.get());
-    }
+    const auto error = DoTexSubImage(gl, target, level, xOffset, yOffset, zOffset, width,
+                                     height, depth, packing, zeros.get());
     if (error)
         return false;
 
     return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -1756,16 +1756,16 @@ ComputeLengthAndData(const dom::ArrayBuf
                      js::Scalar::Type* const out_type);
 
 void
 Intersect(uint32_t srcSize, int32_t dstStartInSrc, uint32_t dstSize,
           uint32_t* const out_intStartInSrc, uint32_t* const out_intStartInDst,
           uint32_t* const out_intSize);
 
 bool
-ZeroTextureData(WebGLContext* webgl, const char* funcName, bool respecifyTexture,
-                GLuint tex, TexImageTarget target, uint32_t level,
+ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
+                TexImageTarget target, uint32_t level,
                 const webgl::FormatUsageInfo* usage, uint32_t xOffset, uint32_t yOffset,
                 uint32_t zOffset, uint32_t width, uint32_t height, uint32_t depth);
 
 } // namespace mozilla
 
 #endif
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -586,24 +586,23 @@ WebGLTexture::EnsureImageDataInitialized
 bool
 WebGLTexture::InitializeImageData(const char* funcName, TexImageTarget target,
                                   uint32_t level)
 {
     auto& imageInfo = ImageInfoAt(target, level);
     MOZ_ASSERT(imageInfo.IsDefined());
     MOZ_ASSERT(!imageInfo.IsDataInitialized());
 
-    const bool respecifyTexture = false;
     const auto& usage = imageInfo.mFormat;
     const auto& width = imageInfo.mWidth;
     const auto& height = imageInfo.mHeight;
     const auto& depth = imageInfo.mDepth;
 
-    if (!ZeroTextureData(mContext, funcName, respecifyTexture, mGLName, target, level,
-                         usage, 0, 0, 0, width, height, depth))
+    if (!ZeroTextureData(mContext, funcName, mGLName, target, level, usage, 0, 0, 0,
+                         width, height, depth))
     {
         return false;
     }
 
     imageInfo.SetIsDataInitialized(true, this);
     return true;
 }
 
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -2074,20 +2074,19 @@ WebGLTexture::CopyTexImage2D(TexImageTar
 
     GLenum error;
     if (rwWidth == uint32_t(width) && rwHeight == uint32_t(height)) {
         error = DoCopyTexImage2D(gl, target, level, internalFormat, x, y, width, height);
     } else {
         // 1. Zero the texture data.
         // 2. CopyTexSubImage the subrect.
 
-        const bool respecifyTexture = true;
         const uint8_t zOffset = 0;
-        if (!ZeroTextureData(mContext, funcName, respecifyTexture, mGLName, target, level,
-                             dstUsage, 0, 0, zOffset, width, height, depth))
+        if (!ZeroTextureData(mContext, funcName, mGLName, target, level, dstUsage, 0, 0,
+                             zOffset, width, height, depth))
         {
             mContext->ErrorOutOfMemory("%s: Failed to zero texture data.", funcName);
             MOZ_ASSERT(false, "Failed to zero texture data.");
             return;
         }
 
         if (!rwWidth || !rwHeight) {
             // There aren't any, so we're 'done'.