Bug 1319004 - Remove workaround for ANGLE. r=jgilbert a=jcristau
authorEthan Lin <ethlin@mozilla.com>
Wed, 23 Nov 2016 00:01:00 +0100
changeset 352727 a8d6dc1f355584378a36b18894fea143e36d80c6
parent 352726 faa34b255f45097c50b4a51061ae30f2cc544ef2
child 352728 8ec3755143534917ca172b8e922d21700a107fe1
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, jcristau
bugs1319004
milestone52.0a2
Bug 1319004 - Remove workaround for ANGLE. r=jgilbert a=jcristau
dom/canvas/WebGLContextGL.cpp
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -1191,108 +1191,22 @@ WebGLContext::PixelStorei(GLenum pname, 
 
     default:
         break;
     }
 
     ErrorInvalidEnumInfo("pixelStorei: parameter", pname);
 }
 
-static bool
-IsNeedsANGLEWorkAround(const webgl::FormatInfo* format)
-{
-    switch (format->effectiveFormat) {
-    case webgl::EffectiveFormat::RGB16F:
-    case webgl::EffectiveFormat::RGBA16F:
-        return true;
-
-    default:
-        return false;
-    }
-}
-
 bool
 WebGLContext::DoReadPixelsAndConvert(const webgl::FormatInfo* srcFormat, GLint x, GLint y,
                                      GLsizei width, GLsizei height, GLenum format,
                                      GLenum destType, void* dest, uint32_t destSize,
                                      uint32_t rowStride)
 {
-    if (gl->WorkAroundDriverBugs() &&
-        gl->IsANGLE() &&
-        gl->Version() < 300 && // ANGLE ES2 doesn't support HALF_FLOAT reads properly.
-        IsNeedsANGLEWorkAround(srcFormat))
-    {
-        MOZ_RELEASE_ASSERT(!IsWebGL2()); // No SKIP_PIXELS, etc.
-        MOZ_ASSERT(!mBoundPixelPackBuffer); // Let's be real clear.
-
-        // You'd think ANGLE would want HALF_FLOAT_OES, but it rejects that.
-        const GLenum readType = LOCAL_GL_HALF_FLOAT;
-
-        const char funcName[] = "readPixels";
-        const auto readBytesPerPixel = webgl::BytesPerPixel({format, readType});
-        const auto destBytesPerPixel = webgl::BytesPerPixel({format, destType});
-
-        uint32_t readStride;
-        uint32_t readByteCount;
-        uint32_t destStride;
-        uint32_t destByteCount;
-        if (!ValidatePackSize(funcName, width, height, readBytesPerPixel, &readStride,
-                              &readByteCount) ||
-            !ValidatePackSize(funcName, width, height, destBytesPerPixel, &destStride,
-                              &destByteCount))
-        {
-            ErrorOutOfMemory("readPixels: Overflow calculating sizes for conversion.");
-            return false;
-        }
-
-        UniqueBuffer readBuffer = malloc(readByteCount);
-        if (!readBuffer) {
-            ErrorOutOfMemory("readPixels: Failed to alloc temp buffer for conversion.");
-            return false;
-        }
-
-        gl::GLContext::LocalErrorScope errorScope(*gl);
-
-        gl->fReadPixels(x, y, width, height, format, readType, readBuffer.get());
-
-        const GLenum error = errorScope.GetError();
-        if (error == LOCAL_GL_OUT_OF_MEMORY) {
-            ErrorOutOfMemory("readPixels: Driver ran out of memory.");
-            return false;
-        }
-
-        if (error) {
-            MOZ_RELEASE_ASSERT(false, "GFX: Unexpected driver error.");
-            return false;
-        }
-
-        size_t channelsPerRow = std::min(readStride / sizeof(uint16_t),
-                                         destStride / sizeof(float));
-
-        const uint8_t* srcRow = (uint8_t*)readBuffer.get();
-        uint8_t* dstRow = (uint8_t*)dest;
-
-        for (size_t j = 0; j < (size_t)height; j++) {
-            auto src = (const uint16_t*)srcRow;
-            auto dst = (float*)dstRow;
-
-            const auto srcEnd = src + channelsPerRow;
-            while (src != srcEnd) {
-                *dst = unpackFromFloat16(*src);
-                ++src;
-                ++dst;
-            }
-
-            srcRow += readStride;
-            dstRow += destStride;
-        }
-
-        return true;
-    }
-
     // On at least Win+NV, we'll get PBO errors if we don't have at least
     // `rowStride * height` bytes available to read into.
     const auto naiveBytesNeeded = CheckedUint32(rowStride) * height;
     const bool isDangerCloseToEdge = (!naiveBytesNeeded.isValid() ||
                                       naiveBytesNeeded.value() > destSize);
     const bool useParanoidHandling = (gl->WorkAroundDriverBugs() &&
                                       isDangerCloseToEdge &&
                                       mBoundPixelPackBuffer);