Fix bugs with drawbuffer state.
* IsAttachmentEnabled was checking the wrong draw buffer state. Instead
of checking that drawbuffer[colorAttachment] is in use, it should have
been scanning for a drawbuffer state that points to colorAttachment.
* Allow for maxDrawBuffer != maxColorAttachments. Tested by the GL
backend on some systems that don't have the draw buffers extension.
Fixed by updating the helpers and adding a new getDrawBuffer helper.
BUG=angleproject:1121
Change-Id: Idd1b0a9ec4a3f944d332c708364408bf5d59e1fd
Reviewed-on: https://chromium-review.googlesource.com/292740
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Tryjob-Request: Geoff Lang <geofflang@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index 6ec11d9..f496449 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -1602,15 +1602,13 @@
return false;
}
- for (size_t colorAttachment = 0;
- colorAttachment < drawFramebuffer->getNumColorBuffers(); ++colorAttachment)
+ for (size_t drawbufferIdx = 0;
+ drawbufferIdx < drawFramebuffer->getDrawbufferStateCount(); ++drawbufferIdx)
{
- if (drawFramebuffer->isEnabledColorAttachment(colorAttachment))
+ const FramebufferAttachment *attachment =
+ drawFramebuffer->getDrawBuffer(drawbufferIdx);
+ if (attachment)
{
- const FramebufferAttachment *attachment =
- drawFramebuffer->getColorbuffer(colorAttachment);
- ASSERT(attachment);
-
if (!(attachment->type() == GL_TEXTURE &&
attachment->getTextureImageIndex().type == GL_TEXTURE_2D) &&
attachment->type() != GL_RENDERBUFFER &&