Implement the WebGL restriction on reading from missing attachments
BUG=angleproject:1523
BUG=chromium:668223
Change-Id: I2dffa3c92dd32e384d3b3109084420650ca7f795
Reviewed-on: https://chromium-review.googlesource.com/421113
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 5a4b256..fb1fc42 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -241,9 +241,13 @@
}
const FramebufferAttachment *readBuffer = framebuffer->getReadColorbuffer();
- if (!readBuffer)
+ // WebGL 1.0 [Section 6.26] Reading From a Missing Attachment
+ // In OpenGL ES it is undefined what happens when an operation tries to read from a missing
+ // attachment and WebGL defines it to be an error. We do the check unconditionnaly as the
+ // situation is an application error that would lead to a crash in ANGLE.
+ if (readBuffer == nullptr)
{
- context->handleError(Error(GL_INVALID_OPERATION));
+ context->handleError(Error(GL_INVALID_OPERATION, "Missing read attachment"));
return false;
}
@@ -2952,6 +2956,16 @@
return false;
}
+ // WebGL 1.0 [Section 6.26] Reading From a Missing Attachment
+ // In OpenGL ES it is undefined what happens when an operation tries to read from a missing
+ // attachment and WebGL defines it to be an error. We do the check unconditionnaly as the
+ // situation is an application error that would lead to a crash in ANGLE.
+ if (readFramebuffer->getReadColorbuffer() == nullptr)
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Missing read attachment"));
+ return false;
+ }
+
const gl::Caps &caps = context->getCaps();
GLuint maxDimension = 0;