Bug 1324157 - Check dst colorDrawBuffers against src in BlitFramebuffer. - r=lenzak800 a=gchang
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 16 Dec 2016 17:48:06 -0800
changeset 353076 171be6aaa16ee1d241ffa4bcdabc95b28372c28b
parent 353075 c6107c5fe98e16ce5b0dba98e879195f24253d5c
child 353077 3eeb3c702723bf933ffc01b58f5fd4f58c243c9f
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)
reviewerslenzak800, gchang
bugs1324157
milestone52.0a2
Bug 1324157 - Check dst colorDrawBuffers against src in BlitFramebuffer. - r=lenzak800 a=gchang MozReview-Commit-ID: 1vzUTG4RD5
dom/canvas/WebGLFramebuffer.cpp
dom/canvas/WebGLFramebuffer.h
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -1044,61 +1044,62 @@ WebGLFramebuffer::ResolvedData::Resolved
     }
     if (parent.mDepthStencilAttachment.IsDefined()) {
         depthBuffer = &parent.mDepthStencilAttachment;
         stencilBuffer = &parent.mDepthStencilAttachment;
     }
 
     ////
 
+    colorDrawBuffers.reserve(parent.mColorDrawBuffers.size());
     texDrawBuffers.reserve(parent.mColorDrawBuffers.size() + 2); // +2 for depth+stencil.
 
     const auto fnCommon = [&](const WebGLFBAttachPoint& attach) {
         if (!attach.IsDefined())
             return false;
 
         hasSampleBuffers |= bool(attach.Samples());
 
         if (attach.Texture()) {
             texDrawBuffers.push_back(&attach);
         }
         return true;
     };
 
     ////
 
-    const auto fnColor = [&](const WebGLFBAttachPoint& attach,
-                             decltype(drawSet)* const out_destSet)
-    {
-        if (!fnCommon(attach))
-            return;
-
-        out_destSet->insert(WebGLFBAttachPoint::Ordered(attach));
-    };
-
     const auto fnDepthStencil = [&](const WebGLFBAttachPoint& attach) {
         if (!fnCommon(attach))
             return;
 
         drawSet.insert(WebGLFBAttachPoint::Ordered(attach));
         readSet.insert(WebGLFBAttachPoint::Ordered(attach));
     };
 
-    ////
-
     fnDepthStencil(parent.mDepthAttachment);
     fnDepthStencil(parent.mStencilAttachment);
     fnDepthStencil(parent.mDepthStencilAttachment);
 
-    for (const auto& attach : parent.mColorDrawBuffers) {
-        fnColor(*attach, &drawSet);
+    ////
+
+    for (const auto& pAttach : parent.mColorDrawBuffers) {
+        const auto& attach = *pAttach;
+        if (!fnCommon(attach))
+            return;
+
+        drawSet.insert(WebGLFBAttachPoint::Ordered(attach));
+        colorDrawBuffers.push_back(&attach);
     }
 
     if (parent.mColorReadBuffer) {
-        fnColor(*(parent.mColorReadBuffer), &readSet);
+        const auto& attach = *parent.mColorReadBuffer;
+        if (!fnCommon(attach))
+            return;
+
+        readSet.insert(WebGLFBAttachPoint::Ordered(attach));
     }
 }
 
 void
 WebGLFramebuffer::RefreshResolvedData()
 {
     if (mResolvedCompleteData) {
         mResolvedCompleteData.reset(new ResolvedData(*this));
@@ -1617,30 +1618,31 @@ WebGLFramebuffer::BlitFramebuffer(WebGLC
             return webgl::ComponentType::Float;
 
         default:
             return format->componentType;
         }
     };
 
     const auto fnCheckColorFormat = [&](const webgl::FormatInfo* dstFormat) {
+        MOZ_ASSERT(dstFormat->r || dstFormat->g || dstFormat->b || dstFormat->a);
         dstHasColor = true;
         colorFormatsMatch &= (dstFormat == srcColorFormat);
         colorTypesMatch &= ( fnNarrowComponentType(dstFormat) ==
                              fnNarrowComponentType(srcColorFormat) );
     };
 
     if (dstFB) {
         dstSampleBuffers = dstFB->mResolvedCompleteData->hasSampleBuffers;
 
         dstDepthFormat = fnGetFormat(dstFB->mResolvedCompleteData->depthBuffer);
         dstStencilFormat = fnGetFormat(dstFB->mResolvedCompleteData->stencilBuffer);
 
-        for (const auto& drawBufferEntry : dstFB->mResolvedCompleteData->drawSet) {
-            fnCheckColorFormat(drawBufferEntry.mRef.Format()->format);
+        for (const auto& cur : dstFB->mResolvedCompleteData->colorDrawBuffers) {
+            fnCheckColorFormat(cur->Format()->format);
         }
     } else {
         dstSampleBuffers = bool(gl->Screen()->Samples());
 
         const webgl::FormatInfo* dstColorFormat;
         GetBackbufferFormats(webgl, &dstColorFormat, &dstDepthFormat, &dstStencilFormat);
 
         fnCheckColorFormat(dstColorFormat);
--- a/dom/canvas/WebGLFramebuffer.h
+++ b/dom/canvas/WebGLFramebuffer.h
@@ -168,16 +168,17 @@ protected:
     std::vector<const WebGLFBAttachPoint*> mColorDrawBuffers; // Non-null
     const WebGLFBAttachPoint* mColorReadBuffer; // Null if NONE
 
     ////
 
     struct ResolvedData {
         // BlitFramebuffer
         bool hasSampleBuffers;
+        std::vector<const WebGLFBAttachPoint*> colorDrawBuffers;
         const WebGLFBAttachPoint* depthBuffer;
         const WebGLFBAttachPoint* stencilBuffer;
 
         // IsFeedback
         std::vector<const WebGLFBAttachPoint*> texDrawBuffers; // Non-null
         std::set<WebGLFBAttachPoint::Ordered> drawSet;
         std::set<WebGLFBAttachPoint::Ordered> readSet;