Bug 1303879 - Validate attachments inside ScopedResolveTextures. - r=mtseng
MozReview-Commit-ID: 7HLiUV9QcY4
--- a/dom/canvas/WebGLContextDraw.cpp
+++ b/dom/canvas/WebGLContextDraw.cpp
@@ -99,17 +99,24 @@ ScopedResolveTexturesForDraw::ScopedReso
mWebGL->ErrorInvalidOperation("%s: The current program is not linked.", funcName);
*out_error = true;
return;
}
const std::vector<const WebGLFBAttachPoint*>* attachList = nullptr;
const auto& fb = mWebGL->mBoundDrawFramebuffer;
if (fb) {
+ if (!fb->ValidateAndInitAttachments(funcName)) {
+ *out_error = true;
+ return;
+ }
+
attachList = &(fb->ResolvedCompleteData()->texDrawBuffers);
+ } else {
+ webgl->ClearBackbufferIfNeeded();
}
MOZ_ASSERT(mWebGL->mActiveProgramLinkInfo);
const auto& uniformSamplers = mWebGL->mActiveProgramLinkInfo->uniformSamplers;
for (const auto& uniform : uniformSamplers) {
const auto& texList = *(uniform->mSamplerTexList);
for (const auto& texUnit : uniform->mSamplerValues) {
@@ -291,25 +298,16 @@ WebGLContext::DrawArrays_check(GLint fir
return false;
}
if (uint32_t(primcount) > mMaxFetchedInstances) {
ErrorInvalidOperation("%s: bound instance attribute buffers do not have sufficient size for given primcount", info);
return false;
}
- MOZ_ASSERT(gl->IsCurrent());
-
- if (mBoundDrawFramebuffer) {
- if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(info))
- return false;
- } else {
- ClearBackbufferIfNeeded();
- }
-
if (!DoFakeVertexAttrib0(checked_firstPlusCount.value())) {
return false;
}
return true;
}
void
@@ -492,28 +490,18 @@ WebGLContext::DrawElements_check(GLsizei
// Bug 1008310 - Check if buffer has been used with a different previous type
if (elemArrayBuffer.IsElementArrayUsedWithMultipleTypes()) {
GenerateWarning("%s: bound element array buffer previously used with a type other than "
"%s, this will affect performance.",
info,
WebGLContext::EnumName(type));
}
- MOZ_ASSERT(gl->IsCurrent());
-
- if (mBoundDrawFramebuffer) {
- if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(info))
- return false;
- } else {
- ClearBackbufferIfNeeded();
- }
-
- if (!DoFakeVertexAttrib0(mMaxFetchedVertices)) {
+ if (!DoFakeVertexAttrib0(mMaxFetchedVertices))
return false;
- }
return true;
}
void
WebGLContext::DrawElements(GLenum mode, GLsizei count, GLenum type,
WebGLintptr byteOffset)
{