Bug 1316245 - In ZeroTextureData, bind texture before cleaning it. r=jgilbert a=gchang
authorEthan Lin <ethlin@mozilla.com>
Fri, 18 Nov 2016 00:16:00 -0500
changeset 352970 ec721f96b0356b2d2cb559575f19b38c9d15d4ca
parent 352969 e92c50c1c5cdd95b59f0a72f15e3aa2841908beb
child 352971 d0afc1865fcc78b86da8eafe642c1fc0f764bdbc
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)
reviewersjgilbert, gchang
bugs1316245
milestone52.0a2
Bug 1316245 - In ZeroTextureData, bind texture before cleaning it. r=jgilbert a=gchang
dom/canvas/WebGLContext.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -2297,16 +2297,31 @@ ZeroTextureData(WebGLContext* webgl, con
     // "Doctor, it hurts when I do this!" "Well don't do that!"
     webgl->GenerateWarning("%s: This operation requires zeroing texture data. This is"
                            " slow.",
                            funcName);
 
     gl::GLContext* gl = webgl->GL();
     gl->MakeCurrent();
 
+    GLenum scopeBindTarget;
+    switch (target.get()) {
+    case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+    case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+    case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+    case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+    case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+    case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+        scopeBindTarget = LOCAL_GL_TEXTURE_CUBE_MAP;
+        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) {
@@ -2375,17 +2390,16 @@ 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;
 }