Bug 1355430 - Part2: Implement Require Fastpath for texture copy; r=baku,jgilbert
☠☠ backed out by bdf510d5b027 ☠ ☠
authorChih-Yi Leu <cleu@mozilla.com>
Tue, 11 Apr 2017 17:15:25 +0800
changeset 404116 661144609b7a45bf5449e319378c9964e587d1f1
parent 404115 773f5b2cb868446f8ddd380646f9de4e83127dd4
child 404117 98d3518db0a402d6b1955d927ef5dc0cafe01222
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, jgilbert
bugs1355430
milestone55.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 1355430 - Part2: Implement Require Fastpath for texture copy; r=baku,jgilbert MozReview-Commit-ID: EPNSJbbJHP4
dom/canvas/TexUnpackBlob.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLContextValidate.cpp
dom/webidl/WebGLRenderingContext.webidl
--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -705,19 +705,26 @@ TexUnpackImage::TexOrSubImage(bool isSub
             break;
         }
 
         // Blitting was successful, so we're done!
         *out_error = 0;
         return true;
     } while (false);
 
-    webgl->GeneratePerfWarning("%s: Failed to hit GPU-copy fast-path. (src type %u)"
-                               " Falling back to CPU upload. (%s)",
-                               funcName, uint32_t(mImage->GetFormat()), fallbackReason);
+    const nsPrintfCString perfMsg("%s: Failed to hit GPU-copy fast-path: %s (src type %u)",
+                                  funcName, fallbackReason, uint32_t(mImage->GetFormat()));
+
+    if (webgl->mPixelStore_RequireFastPath) {
+        webgl->ErrorInvalidOperation("%s", perfMsg.BeginReading());
+        return false;
+    }
+
+    webgl->GeneratePerfWarning("%s Falling back to CPU upload.",
+                               perfMsg.BeginReading());
 
     const RefPtr<gfx::SourceSurface> surf = mImage->GetAsSourceSurface();
 
     RefPtr<gfx::DataSourceSurface> dataSurf;
     if (surf) {
         // WARNING: OSX can lose our MakeCurrent here.
         dataSurf = surf->GetDataSurface();
     }
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -316,16 +316,19 @@ class WebGLContext
     friend class WebGLExtensionLoseContext;
     friend class WebGLExtensionVertexArray;
     friend class WebGLMemoryTracker;
     friend struct webgl::UniformBlockInfo;
 
     enum {
         UNPACK_FLIP_Y_WEBGL = 0x9240,
         UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
+        // We throw InvalidOperation in TexImage if we fail to use GPU fast-path
+        // for texture copy when it is set to true, only for debug purpose.
+        UNPACK_REQUIRE_FASTPATH = 0x10001,
         CONTEXT_LOST_WEBGL = 0x9242,
         UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
         BROWSER_DEFAULT_WEBGL = 0x9244,
         UNMASKED_VENDOR_WEBGL = 0x9245,
         UNMASKED_RENDERER_WEBGL = 0x9246
     };
 
     static const uint32_t kMinMaxColorAttachments;
@@ -1866,16 +1869,17 @@ protected:
 
     bool ValidatePackSize(const char* funcName, uint32_t width, uint32_t height,
                           uint8_t bytesPerPixel, uint32_t* const out_rowStride,
                           uint32_t* const out_endOffset);
 
     GLenum mPixelStore_ColorspaceConversion;
     bool mPixelStore_FlipY;
     bool mPixelStore_PremultiplyAlpha;
+    bool mPixelStore_RequireFastPath;
 
     ////////////////////////////////////
     class FakeBlackTexture {
     public:
         static UniquePtr<FakeBlackTexture> Create(gl::GLContext* gl,
                                                   TexTarget target,
                                                   FakeBlackType type);
         gl::GLContext* const mGL;
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -1123,16 +1123,23 @@ WebGLContext::PixelStorei(GLenum pname, 
             return;
 
         default:
             ErrorInvalidEnumInfo("pixelStorei: colorspace conversion parameter",
                                  param);
             return;
         }
 
+    case UNPACK_REQUIRE_FASTPATH:
+        if (IsExtensionEnabled(WebGLExtensionID::MOZ_debug)) {
+            mPixelStore_RequireFastPath = bool(param);
+            return;
+        }
+        break;
+
     case LOCAL_GL_PACK_ALIGNMENT:
     case LOCAL_GL_UNPACK_ALIGNMENT:
         switch (param) {
         case 1:
         case 2:
         case 4:
         case 8:
             if (pname == LOCAL_GL_PACK_ALIGNMENT)
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -696,16 +696,17 @@ WebGLContext::InitAndValidateGL(FailureR
     if (gl->IsCoreProfile()) {
         mDefaultVertexArray->GenVertexArray();
         mDefaultVertexArray->BindVertexArray();
     }
 
     mPixelStore_FlipY = false;
     mPixelStore_PremultiplyAlpha = false;
     mPixelStore_ColorspaceConversion = BROWSER_DEFAULT_WEBGL;
+    mPixelStore_RequireFastPath = false;
 
     // GLES 3.0.4, p259:
     mPixelStore_UnpackImageHeight = 0;
     mPixelStore_UnpackSkipImages = 0;
     mPixelStore_UnpackRowLength = 0;
     mPixelStore_UnpackSkipRows = 0;
     mPixelStore_UnpackSkipPixels = 0;
     mPixelStore_UnpackAlignment = 4;
--- a/dom/webidl/WebGLRenderingContext.webidl
+++ b/dom/webidl/WebGLRenderingContext.webidl
@@ -1083,12 +1083,13 @@ interface EXT_disjoint_timer_query {
     any getQueryEXT(GLenum target, GLenum pname);
     any getQueryObjectEXT(WebGLQuery query, GLenum pname);
 };
 
 [NoInterfaceObject]
 interface MOZ_debug {
     const GLenum EXTENSIONS = 0x1F03;
     const GLenum WSI_INFO   = 0x10000;
+    const GLenum UNPACK_REQUIRE_FASTPATH = 0x10001;
 
     [Throws]
     any getParameter(GLenum pname);
 };