Bug 1324157 - Check dst colorDrawBuffers against src in BlitFramebuffer. - r=cleu
MozReview-Commit-ID: 1vzUTG4RD5
--- 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;