Bug 1305832 - ZeroTextureData doesn't need x/y/zOffset, so remove those args. - r=ethlin a=gchang
☠☠ backed out by 0da2d0158f98 ☠ ☠
authorJeff Gilbert <jdashg@gmail.com>
Tue, 27 Sep 2016 13:00:57 -0700
changeset 353005 10ea91ee54bd6602ab2956bcbf900775a92fa580
parent 353004 fe0a30186fcc65c67dacd0928b1ca30394bb6616
child 353006 4e602c1e307ef31394b4d9058cbeea7050cc0a8f
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersethlin, gchang
bugs1305832
milestone52.0a2
Bug 1305832 - ZeroTextureData doesn't need x/y/zOffset, so remove those args. - r=ethlin a=gchang
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
@@ -2283,18 +2283,18 @@ ZeroTexImageWithClear(WebGLContext* webg
     }
 
     return true;
 }
 
 bool
 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)
+                const webgl::FormatUsageInfo* usage, 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)
 
     // We have no sympathy for any of these cases.
@@ -2319,18 +2319,16 @@ ZeroTextureData(WebGLContext* webgl, con
         break;
     default:
         scopeBindTarget = target.get();
         break;
     }
     ScopedBindTexture scopeBindTexture(gl, tex, scopeBindTarget);
     auto compression = usage->format->compression;
     if (compression) {
-        MOZ_RELEASE_ASSERT(!xOffset && !yOffset && !zOffset, "GFX: Can't zero compressed texture with offsets.");
-
         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;
         };
 
         const auto widthBlocks = fnSizeInBlocks(width, compression->blockWidth);
@@ -2349,23 +2347,20 @@ 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 = DoCompressedTexSubImage(gl, target.get(), level, xOffset, yOffset,
-                                               zOffset, width, height, depth, sizedFormat,
-                                               byteCount, zeros.get());
-        if (error)
-            return false;
-
-        return true;
+        const auto error = DoCompressedTexSubImage(gl, target.get(), level, 0, 0, 0,
+                                                   width, height, depth, sizedFormat,
+                                                   byteCount, zeros.get());
+        return !error;
     }
 
     const auto driverUnpackInfo = usage->idealUnpack;
     MOZ_RELEASE_ASSERT(driverUnpackInfo, "GFX: ideal unpack info not set.");
 
     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,
@@ -2389,22 +2384,19 @@ ZeroTextureData(WebGLContext* webgl, con
     const size_t byteCount = checkedByteCount.value();
 
     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.
-    const auto error = DoTexSubImage(gl, target, level, xOffset, yOffset, zOffset, width,
-                                     height, depth, packing, zeros.get());
-    if (error)
-        return false;
-
-    return true;
+    const auto error = DoTexSubImage(gl, target, level, 0, 0, 0, width, height, depth,
+                                     packing, zeros.get());
+    return !error;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 CheckedUint32
 WebGLContext::GetUnpackSize(bool isFunc3D, uint32_t width, uint32_t height,
                             uint32_t depth, uint8_t bytesPerPixel)
 {
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -2126,18 +2126,18 @@ private:
 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, 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);
+                const webgl::FormatUsageInfo* usage, uint32_t width, uint32_t height,
+                uint32_t depth);
 
 ////
 
 void
 ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& callback,
                             const std::vector<IndexedBufferBinding>& field,
                             const char* name, uint32_t flags = 0);
 
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -591,18 +591,18 @@ WebGLTexture::InitializeImageData(const 
     MOZ_ASSERT(imageInfo.IsDefined());
     MOZ_ASSERT(!imageInfo.IsDataInitialized());
 
     const auto& usage = imageInfo.mFormat;
     const auto& width = imageInfo.mWidth;
     const auto& height = imageInfo.mHeight;
     const auto& depth = imageInfo.mDepth;
 
-    if (!ZeroTextureData(mContext, funcName, mGLName, target, level, usage, 0, 0, 0,
-                         width, height, depth))
+    if (!ZeroTextureData(mContext, funcName, mGLName, target, level, usage, width, height,
+                         depth))
     {
         return false;
     }
 
     imageInfo.SetIsDataInitialized(true, this);
     return true;
 }
 
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -2006,31 +2006,31 @@ WebGLTexture::CopyTexImage2D(TexImageTar
             break;
 
         if (error)
             break;
 
         // 1. Zero the texture data.
         // 2. CopyTexSubImage the subrect.
 
-        const uint8_t zOffset = 0;
-        if (!ZeroTextureData(mContext, funcName, mGLName, target, level, dstUsage, 0, 0,
-                             zOffset, width, height, depth))
+        if (!ZeroTextureData(mContext, funcName, mGLName, target, level, dstUsage, 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'.
             mContext->DummyReadFramebufferOperation(funcName);
             return;
         }
 
+        const uint8_t zOffset = 0;
         error = DoCopyTexSubImage(gl, target, level, writeX, writeY, zOffset, readX,
                                   readY, rwWidth, rwHeight);
     } while (false);
 
     if (error == LOCAL_GL_OUT_OF_MEMORY) {
         mContext->ErrorOutOfMemory("%s: Ran out of memory during texture copy.",
                                    funcName);
         return;